如何在3D空间中检测点是否在锥体内?

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)

所以你投射pdir沿着轴找到点的距离:

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)


Ign*_*ams 5

圆锥只是无数个圆,其大小由线性方程定义,该方程取得距离点的距离.只需检查它是否在适当大小的圆圈内.


gno*_*ice 5

与语言无关的答案:

  • 找到定义圆锥主轴的直线方程.
  • 计算从3D点到直线距离,以及沿直线与直线垂直的直线的交点.
  • 在交点处找到圆锥的半径,并检查直线与3D点之间的距离是否大于(外部)或小于(内部)该半径.