Projections' Angle of Line in Space

柔情痞子 提交于 2020-01-06 23:52:11

问题


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:

  1. Obtaining the direction of the line, d = (xp - xc, yp - yc, zp - zc)

  2. Normalizing d

  3. Calculating the dot-product with the normal of the plane, dot(d, n) = d.x * n.x + d.y * n.y + d.z * n.z

  4. Calculating the angle to the normal by a = acos(dot(d, n))

  5. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!