I have trouble finding the rotation angle for a cylinder (which is to be a screw hole).
I have the start coordinates and almost a destination point. Not exactly, but did tests with points nearby the intended target. No way the cylinder goes thru. Tried angles normalized, unnormalized, all the 6 permutations of the output, nothing works.
I wrote something like this:
function NormalizeAngle(x) = iif(x<0,180+abs(x),x);
function GetRotationAngles3d(point,pole)=
let (
aXY=NormalizeAngle(atan2(point[1]-pole[1],point[0]-pole[0])),
aXZ=NormalizeAngle(atan2(point[2]-pole[2],point[0]-pole[0])),
aYZ=NormalizeAngle(atan2(point[2]-pole[2],point[1]-pole[1]))
)
[aXY, aXZ, aYZ];
function GetRotationAnglesForRotate(point,pole)=
let (
temp=GetRotationAngles3d(point,pole)
)
[temp[0],temp[1],temp[2]];
Where am I wrong ? How can I get the rotation angles ?