投影的空间线 [英] Projections' Angle of Line in Space
问题描述
起始行(黄色)和轴位于 [xc,yc,zc]
行在 [xp,yp,zc]
。
a
, b
, c
是线条在空间中的角度。
我需要的是线条投影(黑色线条)在xy,yz和xz平面上创建的角度。
A_y_to_z
:在xz平面上从y轴到z轴的投影线角度。
A_x_to_y
:xy平面上从x轴到y轴的角度
在 Matlab上编写代码$ c
$ b
您可以通过以下方式计算投影角度:
-
获取线的方向,
d =(xp - xc,yp - yc,zp - zc)
-
正常化
d
使用平面的普通计算点积, -
通过
a = acos(dot (d,n))
-
最后通过取
b = 90 - 一个
(假设单位为度 - NB最常用数学库f使用弧度)
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.Obtaining the direction of the line,
d = (xp - xc, yp - yc, zp - zc)
Normalizing
d
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
Calculating 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)
dot(d,n)= dx * nx + dy * ny + dz * nz
特例:if dot(d,n)< 0
,那么角度 a
将大于90度。在这种情况下,如果你只想要尖锐的角度,做 b = a - 90
而不是 90 - a
。
例如要计算到xy平面的角度,请使用 n =(0,0,1)
,即z轴,该平面是该平面的法线。
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.
Writing code on Matlab
解决方案 You can calculate the projection angle to any plane by:
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.
这篇关于投影的空间线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!