R
Robin2
Thu, Sep 5, 2019 11:29 AM
I have not been able to find an answer to this with Google or after a lot of
YouTube browsing - it may just be that I don't know the correct search
terms.
If I create a cube I know that each of the vertical faces is at 90deg so it
is easy to rotate a cylinder so it sits perpendicular to a face.
But if I create a prism by extruding a polygon with one face of the prism at
a slope how do I rotate a cylinder so it sits perpendicular to the sloping
face?
With Freecad and SolveSpace it is possible to start a sketch on any surface
of an object but that concept does not exist with Openscad. However I find
the way that Openscad works much easier to deal with.
Thanks
...R
--
Sent from: http://forum.openscad.org/
I have not been able to find an answer to this with Google or after a lot of
YouTube browsing - it may just be that I don't know the correct search
terms.
If I create a cube I know that each of the vertical faces is at 90deg so it
is easy to rotate a cylinder so it sits perpendicular to a face.
But if I create a prism by extruding a polygon with one face of the prism at
a slope how do I rotate a cylinder so it sits perpendicular to the sloping
face?
With Freecad and SolveSpace it is possible to start a sketch on any surface
of an object but that concept does not exist with Openscad. However I find
the way that Openscad works much easier to deal with.
Thanks
...R
--
Sent from: http://forum.openscad.org/
NH
nop head
Thu, Sep 5, 2019 11:29 AM
You have to use trigonometry to work out the angle of the face from the
polygons coordinates. Most likely atan( diff in y, diff in x).
On Thu, 5 Sep 2019 at 12:25, Robin2 robin@nbleopard.com wrote:
I have not been able to find an answer to this with Google or after a lot
of
YouTube browsing - it may just be that I don't know the correct search
terms.
If I create a cube I know that each of the vertical faces is at 90deg so it
is easy to rotate a cylinder so it sits perpendicular to a face.
But if I create a prism by extruding a polygon with one face of the prism
at
a slope how do I rotate a cylinder so it sits perpendicular to the sloping
face?
With Freecad and SolveSpace it is possible to start a sketch on any surface
of an object but that concept does not exist with Openscad. However I find
the way that Openscad works much easier to deal with.
Thanks
...R
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
You have to use trigonometry to work out the angle of the face from the
polygons coordinates. Most likely atan( diff in y, diff in x).
On Thu, 5 Sep 2019 at 12:25, Robin2 <robin@nbleopard.com> wrote:
> I have not been able to find an answer to this with Google or after a lot
> of
> YouTube browsing - it may just be that I don't know the correct search
> terms.
>
> If I create a cube I know that each of the vertical faces is at 90deg so it
> is easy to rotate a cylinder so it sits perpendicular to a face.
>
> But if I create a prism by extruding a polygon with one face of the prism
> at
> a slope how do I rotate a cylinder so it sits perpendicular to the sloping
> face?
>
> With Freecad and SolveSpace it is possible to start a sketch on any surface
> of an object but that concept does not exist with Openscad. However I find
> the way that Openscad works much easier to deal with.
>
> Thanks
>
> ...R
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
P
PhilipJ
Thu, Sep 5, 2019 12:01 PM
Not sure if this will help but I worked out this routine to draw a cylinder
between two arbitrary points.
/************************************
-
*
- Draw a rod between two arbitrary points *
- p1 and p2 are the end points [x,y,z] *
- The diameter of the rod is 'dia/2' and *
- each end point is 'marked' with a sphere *
- of diameter 'dia'. *
-
*
***********************************/
module rod(p1, p2, dia)
{
Xdist = p2[0] - p1[0];
Ydist = p2[1] - p1[1];
Zdist = p2[2] - p1[2];
length = norm([Xdist,Ydist,Zdist]); // radial distance
b = acos(Zdist/length); // inclination angle
c = atan2(Ydist,Xdist); // azimuthal angle
translate(p1)
{
rotate([0, b, c])
{
cylinder(h=length, d=dia);
}
}
}
PhilipJ
--
Sent from: http://forum.openscad.org/
Not sure if this will help but I worked out this routine to draw a cylinder
between two arbitrary points.
/************************************
* *
* Draw a rod between two arbitrary points *
* p1 and p2 are the end points [x,y,z] *
* The diameter of the rod is 'dia/2' and *
* each end point is 'marked' with a sphere *
* of diameter 'dia'. *
* *
***********************************/
module rod(p1, p2, dia)
{
Xdist = p2[0] - p1[0];
Ydist = p2[1] - p1[1];
Zdist = p2[2] - p1[2];
length = norm([Xdist,Ydist,Zdist]); // radial distance
b = acos(Zdist/length); // inclination angle
c = atan2(Ydist,Xdist); // azimuthal angle
translate(p1)
{
rotate([0, b, c])
{
cylinder(h=length, d=dia);
}
}
}
PhilipJ
--
Sent from: http://forum.openscad.org/
L
lar3ry
Thu, Sep 5, 2019 1:58 PM
I would probably use one of the formulae for finding the slope of a line.
There's a handy calulator for it...
https://www.omnicalculator.com/math/slope that also shows the formulae.
A quick Google, using the term "find the slope of a line" brought up a lot
of hits.
--
Sent from: http://forum.openscad.org/
I would probably use one of the formulae for finding the slope of a line.
There's a handy calulator for it...
https://www.omnicalculator.com/math/slope that also shows the formulae.
A quick Google, using the term "find the slope of a line" brought up a lot
of hits.
--
Sent from: http://forum.openscad.org/
R
Robin2
Thu, Sep 5, 2019 4:56 PM
Thanks for the answers. I had been assuming that there is a simpler way
within Openscad that I had missed. Must brush off my sin cos and tan.
Just out of curiosity is the need to align things with sloping sides
something that is rarely if ever needed in practice?
...R
--
Sent from: http://forum.openscad.org/
Thanks for the answers. I had been assuming that there is a simpler way
within Openscad that I had missed. Must brush off my sin cos and tan.
Just out of curiosity is the need to align things with sloping sides
something that is rarely if ever needed in practice?
...R
--
Sent from: http://forum.openscad.org/
A
adrianv
Thu, Sep 5, 2019 9:47 PM
I think the idea that you should use trig every time you want to position an
object is absurd. The computer should do the trig and you should think
about your model. And I say this as someone who is totally comfortable
with trigonometry. The key is to use (or write) libraries that do what you
need.
I'm not quite sure exactly what you want to do, but the Relativity library
might be able to help. There's also the attachment code in the Obiscad
library. And the experimental BOSL2 library has an attachments
functionality as well. If BOSL2 doesn't do what you want, now's the time to
ask for changes, while the library is still in the rapid development phase
and not trying to maintain backward compatibility.
Here's an example:
include<BOSL2/std.scad>
prismoid(size1=[50,30], size2=[20,20], h=20, shift=[15,5])
attach(LEFT)cyl(h=10,r=3);
And the result:
http://forum.openscad.org/file/t2477/attach.png
Robin2 wrote
Thanks for the answers. I had been assuming that there is a simpler way
within Openscad that I had missed. Must brush off my sin cos and tan.
Just out of curiosity is the need to align things with sloping sides
something that is rarely if ever needed in practice?
I think the idea that you should use trig every time you want to position an
object is absurd. The computer should do the trig and you should think
about your model. And I say this as someone who is totally comfortable
with trigonometry. The key is to use (or write) libraries that do what you
need.
I'm not quite sure exactly what you want to do, but the Relativity library
might be able to help. There's also the attachment code in the Obiscad
library. And the experimental BOSL2 library has an attachments
functionality as well. If BOSL2 doesn't do what you want, now's the time to
ask for changes, while the library is still in the rapid development phase
and not trying to maintain backward compatibility.
Here's an example:
include<BOSL2/std.scad>
prismoid(size1=[50,30], size2=[20,20], h=20, shift=[15,5])
attach(LEFT)cyl(h=10,r=3);
And the result:
<http://forum.openscad.org/file/t2477/attach.png>
Robin2 wrote
> Thanks for the answers. I had been assuming that there is a simpler way
> within Openscad that I had missed. Must brush off my sin cos and tan.
>
> Just out of curiosity is the need to align things with sloping sides
> something that is rarely if ever needed in practice?
--
Sent from: http://forum.openscad.org/
NH
nop head
Thu, Sep 5, 2019 10:16 PM
I think the idea that you should use trig every time you want to position
an object is absurd.
Well for me trig is trivial but I have no idea what that BSOL code does, or
how it works. I would have to look it up but I know what atan2 does.
On Thu, 5 Sep 2019 at 22:43, adrianv avm4@cornell.edu wrote:
I think the idea that you should use trig every time you want to position
an
object is absurd. The computer should do the trig and you should think
about your model. And I say this as someone who is totally comfortable
with trigonometry. The key is to use (or write) libraries that do what
you
need.
I'm not quite sure exactly what you want to do, but the Relativity library
might be able to help. There's also the attachment code in the Obiscad
library. And the experimental BOSL2 library has an attachments
functionality as well. If BOSL2 doesn't do what you want, now's the time to
ask for changes, while the library is still in the rapid development phase
and not trying to maintain backward compatibility.
Here's an example:
include<BOSL2/std.scad>
prismoid(size1=[50,30], size2=[20,20], h=20, shift=[15,5])
attach(LEFT)cyl(h=10,r=3);
And the result:
http://forum.openscad.org/file/t2477/attach.png
Robin2 wrote
Thanks for the answers. I had been assuming that there is a simpler way
within Openscad that I had missed. Must brush off my sin cos and tan.
Just out of curiosity is the need to align things with sloping sides
something that is rarely if ever needed in practice?
>I think the idea that you should use trig every time you want to position
an object is absurd.
Well for me trig is trivial but I have no idea what that BSOL code does, or
how it works. I would have to look it up but I know what atan2 does.
On Thu, 5 Sep 2019 at 22:43, adrianv <avm4@cornell.edu> wrote:
> I think the idea that you should use trig every time you want to position
> an
> object is absurd. The computer should do the trig and you should think
> about your model. And I say this as someone who is totally comfortable
> with trigonometry. The key is to use (or write) libraries that do what
> you
> need.
>
> I'm not quite sure exactly what you want to do, but the Relativity library
> might be able to help. There's also the attachment code in the Obiscad
> library. And the experimental BOSL2 library has an attachments
> functionality as well. If BOSL2 doesn't do what you want, now's the time to
> ask for changes, while the library is still in the rapid development phase
> and not trying to maintain backward compatibility.
>
> Here's an example:
>
> include<BOSL2/std.scad>
> prismoid(size1=[50,30], size2=[20,20], h=20, shift=[15,5])
> attach(LEFT)cyl(h=10,r=3);
>
> And the result:
> <http://forum.openscad.org/file/t2477/attach.png>
>
>
> Robin2 wrote
> > Thanks for the answers. I had been assuming that there is a simpler way
> > within Openscad that I had missed. Must brush off my sin cos and tan.
> >
> > Just out of curiosity is the need to align things with sloping sides
> > something that is rarely if ever needed in practice?
>
>
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
AC
A. Craig West
Thu, Sep 5, 2019 10:35 PM
At some level, you will always be doing trig. You just need to write or
find a function that calculates the correct angle using trig, and call that
whenever you need to. It's pretty much the openscad way. Hopefully you
don't have to haul out a calculator and figure it out manually every time
On Thu, 5 Sep 2019, 18:18 nop head, nop.head@gmail.com wrote:
I think the idea that you should use trig every time you want to position
an object is absurd.
Well for me trig is trivial but I have no idea what that BSOL code does,
or how it works. I would have to look it up but I know what atan2 does.
On Thu, 5 Sep 2019 at 22:43, adrianv avm4@cornell.edu wrote:
I think the idea that you should use trig every time you want to position
an
object is absurd. The computer should do the trig and you should think
about your model. And I say this as someone who is totally comfortable
with trigonometry. The key is to use (or write) libraries that do what
you
need.
I'm not quite sure exactly what you want to do, but the Relativity library
might be able to help. There's also the attachment code in the Obiscad
library. And the experimental BOSL2 library has an attachments
functionality as well. If BOSL2 doesn't do what you want, now's the time
to
ask for changes, while the library is still in the rapid development phase
and not trying to maintain backward compatibility.
Here's an example:
include<BOSL2/std.scad>
prismoid(size1=[50,30], size2=[20,20], h=20, shift=[15,5])
attach(LEFT)cyl(h=10,r=3);
And the result:
http://forum.openscad.org/file/t2477/attach.png
Robin2 wrote
Thanks for the answers. I had been assuming that there is a simpler way
within Openscad that I had missed. Must brush off my sin cos and tan.
Just out of curiosity is the need to align things with sloping sides
something that is rarely if ever needed in practice?
At some level, you will always be doing trig. You just need to write or
find a function that calculates the correct angle using trig, and call that
whenever you need to. It's pretty much the openscad way. Hopefully you
don't have to haul out a calculator and figure it out manually every time
On Thu, 5 Sep 2019, 18:18 nop head, <nop.head@gmail.com> wrote:
> >I think the idea that you should use trig every time you want to position
> an object is absurd.
>
> Well for me trig is trivial but I have no idea what that BSOL code does,
> or how it works. I would have to look it up but I know what atan2 does.
>
> On Thu, 5 Sep 2019 at 22:43, adrianv <avm4@cornell.edu> wrote:
>
>> I think the idea that you should use trig every time you want to position
>> an
>> object is absurd. The computer should do the trig and you should think
>> about your model. And I say this as someone who is totally comfortable
>> with trigonometry. The key is to use (or write) libraries that do what
>> you
>> need.
>>
>> I'm not quite sure exactly what you want to do, but the Relativity library
>> might be able to help. There's also the attachment code in the Obiscad
>> library. And the experimental BOSL2 library has an attachments
>> functionality as well. If BOSL2 doesn't do what you want, now's the time
>> to
>> ask for changes, while the library is still in the rapid development phase
>> and not trying to maintain backward compatibility.
>>
>> Here's an example:
>>
>> include<BOSL2/std.scad>
>> prismoid(size1=[50,30], size2=[20,20], h=20, shift=[15,5])
>> attach(LEFT)cyl(h=10,r=3);
>>
>> And the result:
>> <http://forum.openscad.org/file/t2477/attach.png>
>>
>>
>> Robin2 wrote
>> > Thanks for the answers. I had been assuming that there is a simpler way
>> > within Openscad that I had missed. Must brush off my sin cos and tan.
>> >
>> > Just out of curiosity is the need to align things with sloping sides
>> > something that is rarely if ever needed in practice?
>>
>>
>>
>>
>>
>> --
>> Sent from: http://forum.openscad.org/
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> Discuss@lists.openscad.org
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
A
adrianv
Thu, Sep 5, 2019 11:28 PM
"At some level"? Of course, trigonometric calculations are occurring. But
I'm not doing them if I didn't type "cos" in myself. If they are
encapsulated in a library call then those calculations are happening at a
level down. When I issue a rotate command in OpenSCAD, trigonometric
calculations are necessary to determine the transformation. But I am not
doing them. They are done for me, built in to OpenSCAD. I think
rotate(theta) not [[cos(theta),sin(theta)],[-sin(theta),cos(theta]]. I
disagree that "The OpenSCAD Way" is to get down and dirty with sine and
cosine every time things are not at right angles.
Yes, some task might be done by a function that uses trigonometry, but the
higher level abstraction of hiding the trig in a function will produce code
that is easier to write and easier to read next week. At least, that's my
opinion. And it doesn't just apply to trigonometry, but any geometrical
calculation. I know there are those that disagree. I don''t understand
their perspective. Do they think the "rotate" command is an unnecessary
abstraction because we have multmatrix? Would they really prefer to do the
trig to orient a cylinder onto a face of a dodecahedron instead of having it
done for them? But the original poster seemed interested in a more abstract
approach. I'm just pointing out that such an approach is possible. You
can, of course, also do the trigonometry if you prefer.
acwest wrote
At some level, you will always be doing trig. You just need to write or
find a function that calculates the correct angle using trig, and call
that
whenever you need to. It's pretty much the openscad way. Hopefully you
don't have to haul out a calculator and figure it out manually every time
On Thu, 5 Sep 2019, 18:18 nop head, <
I think the idea that you should use trig every time you want to
position
an object is absurd.
Well for me trig is trivial but I have no idea what that BSOL code does,
or how it works. I would have to look it up but I know what atan2 does.
On Thu, 5 Sep 2019 at 22:43, adrianv <
I think the idea that you should use trig every time you want to
position
an
object is absurd. The computer should do the trig and you should think
about your model. And I say this as someone who is totally comfortable
with trigonometry. The key is to use (or write) libraries that do what
you
need.
I'm not quite sure exactly what you want to do, but the Relativity
library
might be able to help. There's also the attachment code in the Obiscad
library. And the experimental BOSL2 library has an attachments
functionality as well. If BOSL2 doesn't do what you want, now's the time
to
ask for changes, while the library is still in the rapid development
phase
and not trying to maintain backward compatibility.
Here's an example:
include<BOSL2/std.scad>
prismoid(size1=[50,30], size2=[20,20], h=20, shift=[15,5])
attach(LEFT)cyl(h=10,r=3);
And the result:
<http://forum.openscad.org/file/t2477/attach.png>
Robin2 wrote
Thanks for the answers. I had been assuming that there is a simpler
within Openscad that I had missed. Must brush off my sin cos and tan.
Just out of curiosity is the need to align things with sloping sides
something that is rarely if ever needed in practice?
"At some level"? Of course, trigonometric calculations are occurring. But
I'm not doing them if I didn't type "cos" in myself. If they are
encapsulated in a library call then those calculations are happening at a
level down. When I issue a rotate command in OpenSCAD, trigonometric
calculations are necessary to determine the transformation. But I am not
doing them. They are done for me, built in to OpenSCAD. I think
rotate(theta) not [[cos(theta),sin(theta)],[-sin(theta),cos(theta]]. I
disagree that "The OpenSCAD Way" is to get down and dirty with sine and
cosine every time things are not at right angles.
Yes, some task might be done by a function that uses trigonometry, but the
higher level abstraction of hiding the trig in a function will produce code
that is easier to write and easier to read next week. At least, that's my
opinion. And it doesn't just apply to trigonometry, but any geometrical
calculation. I know there are those that disagree. I don''t understand
their perspective. Do they think the "rotate" command is an unnecessary
abstraction because we have multmatrix? Would they really prefer to do the
trig to orient a cylinder onto a face of a dodecahedron instead of having it
done for them? But the original poster seemed interested in a more abstract
approach. I'm just pointing out that such an approach is possible. You
can, of course, also do the trigonometry if you prefer.
acwest wrote
> At some level, you will always be doing trig. You just need to write or
> find a function that calculates the correct angle using trig, and call
> that
> whenever you need to. It's pretty much the openscad way. Hopefully you
> don't have to haul out a calculator and figure it out manually every time
>
> On Thu, 5 Sep 2019, 18:18 nop head, <
> nop.head@
> > wrote:
>
>> >I think the idea that you should use trig every time you want to
>> position
>> an object is absurd.
>>
>> Well for me trig is trivial but I have no idea what that BSOL code does,
>> or how it works. I would have to look it up but I know what atan2 does.
>>
>> On Thu, 5 Sep 2019 at 22:43, adrianv <
> avm4@
> > wrote:
>>
>>> I think the idea that you should use trig every time you want to
>>> position
>>> an
>>> object is absurd. The computer should do the trig and you should think
>>> about your model. And I say this as someone who is totally comfortable
>>> with trigonometry. The key is to use (or write) libraries that do what
>>> you
>>> need.
>>>
>>> I'm not quite sure exactly what you want to do, but the Relativity
>>> library
>>> might be able to help. There's also the attachment code in the Obiscad
>>> library. And the experimental BOSL2 library has an attachments
>>> functionality as well. If BOSL2 doesn't do what you want, now's the time
>>> to
>>> ask for changes, while the library is still in the rapid development
>>> phase
>>> and not trying to maintain backward compatibility.
>>>
>>> Here's an example:
>>>
>>> include<BOSL2/std.scad>
>>> prismoid(size1=[50,30], size2=[20,20], h=20, shift=[15,5])
>>> attach(LEFT)cyl(h=10,r=3);
>>>
>>> And the result:
>>> <http://forum.openscad.org/file/t2477/attach.png>
>>>
>>>
>>> Robin2 wrote
>>> > Thanks for the answers. I had been assuming that there is a simpler
>>> way
>>> > within Openscad that I had missed. Must brush off my sin cos and tan.
>>> >
>>> > Just out of curiosity is the need to align things with sloping sides
>>> > something that is rarely if ever needed in practice?
>>>
>>>
>>>
>>>
>>>
>>> --
>>> Sent from: http://forum.openscad.org/
>>>
>>> _______________________________________________
>>> OpenSCAD mailing list
>>>
> Discuss@.openscad
>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>>
>> _______________________________________________
>> OpenSCAD mailing list
>>
> Discuss@.openscad
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@.openscad
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
Sent from: http://forum.openscad.org/
A
arnholm@arnholm.org
Fri, Sep 6, 2019 5:06 AM
On 2019-09-06 01:28, adrianv wrote:
Yes, some task might be done by a function that uses trigonometry, but
the
higher level abstraction of hiding the trig in a function will produce
code
that is easier to write and easier to read next week. At least, that's
my
opinion. And it doesn't just apply to trigonometry, but any
geometrical
calculation. I know there are those that disagree. I don''t
understand
their perspective. Do they think the "rotate" command is an
unnecessary
abstraction because we have multmatrix? Would they really prefer to
do the
trig to orient a cylinder onto a face of a dodecahedron instead of
having it
done for them? But the original poster seemed interested in a more
abstract
approach. I'm just pointing out that such an approach is possible.
Such an approach is possible (sometimes) if you can query existing
objects for their geometry, and you can't do that in OpenSCAD.
Carsten Arnholm
On 2019-09-06 01:28, adrianv wrote:
> Yes, some task might be done by a function that uses trigonometry, but
> the
> higher level abstraction of hiding the trig in a function will produce
> code
> that is easier to write and easier to read next week. At least, that's
> my
> opinion. And it doesn't just apply to trigonometry, but any
> geometrical
> calculation. I know there are those that disagree. I don''t
> understand
> their perspective. Do they think the "rotate" command is an
> unnecessary
> abstraction because we have multmatrix? Would they really prefer to
> do the
> trig to orient a cylinder onto a face of a dodecahedron instead of
> having it
> done for them? But the original poster seemed interested in a more
> abstract
> approach. I'm just pointing out that such an approach is possible.
Such an approach is possible (sometimes) if you can query existing
objects for their geometry, and you can't do that in OpenSCAD.
Carsten Arnholm