Matlab 如何在三维空间中检测点是否位于圆锥体内部?
如何检测三维点是否位于圆锥体内部Matlab 如何在三维空间中检测点是否位于圆锥体内部?,matlab,c#-4.0,math,Matlab,C# 4.0,Math,如何检测三维点是否位于圆锥体内部 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 = fa
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
圆锥体就是无限多个圆,其大小由一个线性方程定义,该方程取到该点的距离。只需检查它是否在适当大小的圆圈内。要扩展Ignacio的答案: 让 因此,您将
p
投影到dir
上,以查找点沿轴的距离:
cone_dist = dot(p - x, dir)
cone_radius = (cone_dist / h) * r
此时,您可以拒绝语言不可知答案之外的值:
- 找到定义圆锥体主轴的直线方程
- 沿距离垂直于直线的直线上的交点计算
- 在交点处找到圆锥体的半径,然后检查直线与三维点之间的距离是否大于(外部)或小于(内部)该半径
什么坐标系?你是如何表示圆锥体的?这个问题的一个概括(处理椭圆锥体)在我不知道是否有可能更清楚地描述,而数学公式给了我,我只是英语不好。如果你有一张照片那就太好了。我答案的
code
部分就像数学公式和伪代码。我很乐意更详细地解释任何部分。你需要哪一方面的帮助?如果你不熟悉dotproduct在这里的使用方式,这对我很有帮助:为什么我只能更新一次?!:)这是一个非常清晰和简洁的答案,它比我所看到的所有其他资源都能更好地解释问题。
cone_radius = (cone_dist / h) * r
orth_distance = length((p - x) - cone_dist * dir)
is_point_inside_cone = (orth_distance < cone_radius)