[OpenSCAD] finding angle from a coordinate
Ronaldo
rcmpersiano at gmail.com
Wed Oct 12 23:08:07 EDT 2016
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(X*X + Y*Y) / Z), 0])
>
> cylinder(r = R, h = sqrt(X*X + Y*Y + 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.
More information about the Discuss
mailing list