This is my notepad where i collect the useful snippets of OpenSCAD code that i use over and over. Some better curated than others, some formatted for clarity some for efficiency.
Tuesday, May 30, 2017
Angle between two vectors in 3D
Angle between two vectors in 3D Usage:
a=[10,0,0];
b=[0,10,0];
echo(angle(a,b));
function angle (a,b)=atan2(norm(cross(a,b)),a*b);
Nice! You can optimize a bit: atan2(norm(cross(a,b)),a*b). (Untested.)
ReplyDeleteYes! a no brainer when you see it. Thank you and edited.
ReplyDelete