Sab*_*ahi 4 math matlab c#-4.0
如何检测3D点是否在锥体内?
Ross cone = (x1, y1, h1)
Cone angle = alpha
Height of the cone = H
Cone radius = R
Coordinates of the point of the cone = P1 (x2, y2, h2)
Coordinates outside the cone = P2( x3, y3, h3)
Result for point1 = true
Result for point2 = false
Run Code Online (Sandbox Code Playgroud)
jap*_*iss 23
要扩展Ignacio的答案:
让
x = the tip of the cone
dir = the normalized axis vector, pointing from the tip to the base
h = height
r = base radius
p = point to test
Run Code Online (Sandbox Code Playgroud)
所以你投射p到dir沿着轴找到点的距离:
cone_dist = dot(p - x, dir)
Run Code Online (Sandbox Code Playgroud)
此时,您可以拒绝外部的值0 <= cone_dist <= h.
然后计算沿轴的那个点的锥半径:
cone_radius = (cone_dist / h) * r
Run Code Online (Sandbox Code Playgroud)
最后计算点与轴的正交距离,以便与锥半径进行比较:
orth_distance = length((p - x) - cone_dist * dir)
is_point_inside_cone = (orth_distance < cone_radius)
Run Code Online (Sandbox Code Playgroud)