Been a while since I’ve been in a math course but this struck me an not quite correct - and my program does not work correctly. So:
Consider 3 vectors
1, 0, 0 is the reference - the x axis, X
0,0,1 is vector A, the z axis (up)
0,0,-1 is vector B, the -z axis (down)
Now, the angle from A to X is 1.57 radians. So, also, says angle_between.
But, angle_between says B to X is ALSO 1.57 radians.
This cannot be right. B is opposite A. B to X must be 6.123 radians.
OK, some code:
vRef = Geom::Vector3d 1,0,0
vA = Geom::Vector3d 0,0,1
vB = Geom::Vector3d 0,0,-1
puts "vRef to vA is #{vRef.angle_between vA} "
puts “vRef to vB is #{vRef.angle_between vB}”
Results:
vRef to vA is 1.5707963267948966
vRef to vB is 1.5707963267948966
NOT!
You might ask - what is the reference? The right-hand rule via the cross product of the two vectors. Note also the normal of a face - it must be + or - depending on the order of the points that define the face - again by the right-hand rule.