I have a column with a radius of 1.
The column's base is located at 0,0,0, and its top is located at 3,4,5.
As I understand it, to orient the column I need to use rotate, rather than
specify the endpoint.
[code]
translate([0,0,0]) {
rotate([a,b,c]) {
cylinder(r = 1, h = 7.071);
}
}
[/code]
How would I go about finding the angles a,b,c, knowing the endpoint?
Thanks!
--
View this message in context: http://forum.openscad.org/finding-angle-from-a-coordinate-tp18684.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
decompose it into a couple rotates and use some trigonometry:
$fn=30;
X = 3;
Y = 4;
Z = 5;
R = 1;
rotate([0,0,atan(Y/X)])
rotate([0, atan(sqrt(XX + YY) / Z), 0])
cylinder(r = R, h = sqrt(XX + YY + Z*Z));
color("red")
translate([X,Y,Z])
sphere(r=R);
2016-10-12 22:26 GMT-03:00 tony873004 tony@gravitysimulator.com:
I have a column with a radius of 1.
The column's base is located at 0,0,0, and its top is located at 3,4,5.
As I understand it, to orient the column I need to use rotate, rather than
specify the endpoint.
[code]
translate([0,0,0]) {
rotate([a,b,c]) {
cylinder(r = 1, h = 7.071);
}
}
[/code]
How would I go about finding the angles a,b,c, knowing the endpoint?
Thanks!
--
View this message in context: http://forum.openscad.org/finding-angle-from-a-coordinate-tp18684.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
You may try this solution:
Drawing lines...
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Tips_and_Tricks#Drawing_.22lines.22_in_OpenSCAD
2016-10-12 22:26 GMT-03:00 tony873004 tony@gravitysimulator.com:
I have a column with a radius of 1.
The column's base is located at 0,0,0, and its top is located at 3,4,5.
As I understand it, to orient the column I need to use rotate, rather than
specify the endpoint.
[code]
translate([0,0,0]) {
rotate([a,b,c]) {
cylinder(r = 1, h = 7.071);
}
}
[/code]
How would I go about finding the angles a,b,c, knowing the endpoint?
Thanks!
--
View this message in context: http://forum.openscad.org/
finding-angle-from-a-coordinate-tp18684.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Here is my attempt
https://gist.github.com/donbright/b1999d40048b771d32fe9324e904a9f8
It is somewhat certain to work in all 8 octants
--
don bright
hmbright@fastmail.com
On Wed, Oct 12, 2016, at 08:26 PM, tony873004 wrote:
I have a column with a radius of 1.
The column's base is located at 0,0,0, and its top is located at 3,4,5.
As I understand it, to orient the column I need to use rotate, rather
than
specify the endpoint.
[code]
translate([0,0,0]) {
rotate([a,b,c]) {
cylinder(r = 1, h = 7.071);
}
}
[/code]
How would I go about finding the angles a,b,c, knowing the endpoint?
Thanks!
--
View this message in context:
http://forum.openscad.org/finding-angle-from-a-coordinate-tp18684.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Your solution is restricted to X!=0 and Z!=0.
For a robust trigonometric solution, see Rotation Rule
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#Rotation_rule_help
in the manual. It uses atan2().
Felipe Sanches wrote
decompose it into a couple rotates and use some trigonometry:
$fn=30;
X = 3;
Y = 4;
Z = 5;
R = 1;
rotate([0,0,atan(Y/X)])
rotate([0, atan(sqrt(XX + YY) / Z), 0])
cylinder(r = R, h = sqrt(XX + YY + Z*Z));
color("red")
translate([X,Y,Z])
sphere(r=R);
--
View this message in context: http://forum.openscad.org/finding-angle-from-a-coordinate-tp18684p18688.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Thanks for all the fast and great replies!
I'll try them tomorrow and let you know how it goes.
--
View this message in context: http://forum.openscad.org/finding-angle-from-a-coordinate-tp18684p18689.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
The rotation rule from the manual was exactly what I was looking for. Worked
in all 8 octants. Thanks!
--
View this message in context: http://forum.openscad.org/finding-angle-from-a-coordinate-tp18684p18701.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Questions like yours are one of the motivations for a new turtle.scad
library at:
https://github.com/ottojas/openscad-affine
Documentation is in md file and there are some examples. These
avoid explictly calculating the angle.
your program could then be (for cylinder alone)
include <turtle.scad>
path = [[lookAt([3,4,5]),turnDown(90)]];
turtlePath(path){cylinder(r1 = 1, r2= .5, h = 7.071);}
You do not need to do the trig yourself.
Regards
Otto
On Wed, 12 Oct 2016 18:26:59 -0700 (MST)
tony873004 tony@gravitysimulator.com wrote:
I have a column with a radius of 1.
The column's base is located at 0,0,0, and its top is located at
3,4,5. As I understand it, to orient the column I need to use rotate,
rather than specify the endpoint.
[code]
translate([0,0,0]) {
rotate([a,b,c]) {
cylinder(r = 1, h = 7.071);
}
}
[/code]
How would I go about finding the angles a,b,c, knowing the endpoint?
Thanks!
--
View this message in context:
http://forum.openscad.org/finding-angle-from-a-coordinate-tp18684.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org