问题
Start of line (yellow) and axes are at [xc,yc,zc]
End of line is at [xp,yp,zc].
a,b, c are the angles which line makes in space.
What I need are the angles which line's projections (black line) create on xy,yz and xz planes.
A_y_to_z: Projected line's angle from y axis to z axis on xz plane.A_z_to_x: Angle from z to x axis on zx plane.A_x_to_y: Angle from x to y axis on xy plane.
Writing code on Matlab
回答1:
You can calculate the projection angle to any plane by:
Obtaining the direction of the line,
d = (xp - xc, yp - yc, zp - zc)Normalizing
dCalculating the dot-product with the normal of the plane,
dot(d, n) = d.x * n.x + d.y * n.y + d.z * n.zCalculating the angle to the normal by
a = acos(dot(d, n))Finally obtaining the angle to the plane by taking
b = 90 - a(assuming units in degrees - NB most math library functions use radians)
Special case: if dot(d, n) < 0, then the angle a will be greater than 90 degrees. In this case if you only want the acute angle, do b = a - 90 instead of 90 - a.
e.g. To calculate the angle to the xy plane, use n = (0, 0, 1), i.e. the z-axis, which is the normal to that plane.
来源:https://stackoverflow.com/questions/44905459/projections-angle-of-line-in-space