i have the following geometrical issue in 2D:
我在2D中有以下几何问题:
i have a point from which i cast an infinite angle (2D-cone) which is given by a direction and an angle. (the point and the direction form a vector and to each side half of the angle forms the 2D-cone)
我有一个点,我投射一个无限角度(二维圆锥),由一个方向和一个角度给出。 (点和方向形成一个矢量,并且每个角度的一半形成2D锥体)
now i want to check if another point in 2D is inside this cone or outside.
现在我想检查2D中的另一个点是在该锥体内部还是外部。
how can this be achieved? thanks!
怎么能实现呢?谢谢!
4 个解决方案
#1
Calculate the vector from the center of the cone to the query point. Normalize the vector to be of length 1, Take the center vector of the cone and normalize this as well to the length of 1.
Now take the dot product between the vectors. The dot product between two normalized vectors is the cosinus of the angle between them. Take the arccos (acos
in most languages) of the dot product and you'll get the angle. compare this angle to the cone's angle (half angle in your description). if its lower, then point in question is inside the cone.
计算从锥体中心到查询点的向量。将矢量标准化为长度为1,取锥体的中心矢量并将其标准化为长度1.现在取矢量之间的点积。两个归一化向量之间的点积是它们之间角度的余弦。拿点积的arccos(大多数语言为acos)你就会得到角度。将此角度与锥体角度(描述中的半角度)进行比较。如果它较低,那么有问题的点在锥体内。
This works in 2D and 3D.
这适用于2D和3D。
#2
Calculate the angle of the direction using arctg of the direction. Substract the origin from the checked point. Calculate its angle (again via arctg of a normalized vector), and check if it lies within angle boundaries.
使用方向的arctg计算方向的角度。从检查点中减去原点。计算其角度(再次通过标准化矢量的arctg),并检查它是否位于角度边界内。
#3
I would say the best way is to project the point onto the 2D surface perpendicular to the cones direction. Then you calculate the othogonal distance between that same plane and the point. Finally, you know the width of the cone at that height, so you can see if the point is outside that width.
我想说最好的方法是将点投影到垂直于锥体方向的2D表面上。然后计算同一平面和点之间的正交距离。最后,您知道该高度处的圆锥宽度,因此您可以看到该点是否在该宽度之外。
#4
Let the vector from the point of origin to the specified point makes an angle A with the normal that runs through the center. If the angle A is less than the half angle of the cone it lies inside else outside.
让从原点到指定点的矢量与穿过中心的法线成一个角度A.如果角度A小于锥体的半角,则它位于其他外部。
#1
Calculate the vector from the center of the cone to the query point. Normalize the vector to be of length 1, Take the center vector of the cone and normalize this as well to the length of 1.
Now take the dot product between the vectors. The dot product between two normalized vectors is the cosinus of the angle between them. Take the arccos (acos
in most languages) of the dot product and you'll get the angle. compare this angle to the cone's angle (half angle in your description). if its lower, then point in question is inside the cone.
计算从锥体中心到查询点的向量。将矢量标准化为长度为1,取锥体的中心矢量并将其标准化为长度1.现在取矢量之间的点积。两个归一化向量之间的点积是它们之间角度的余弦。拿点积的arccos(大多数语言为acos)你就会得到角度。将此角度与锥体角度(描述中的半角度)进行比较。如果它较低,那么有问题的点在锥体内。
This works in 2D and 3D.
这适用于2D和3D。
#2
Calculate the angle of the direction using arctg of the direction. Substract the origin from the checked point. Calculate its angle (again via arctg of a normalized vector), and check if it lies within angle boundaries.
使用方向的arctg计算方向的角度。从检查点中减去原点。计算其角度(再次通过标准化矢量的arctg),并检查它是否位于角度边界内。
#3
I would say the best way is to project the point onto the 2D surface perpendicular to the cones direction. Then you calculate the othogonal distance between that same plane and the point. Finally, you know the width of the cone at that height, so you can see if the point is outside that width.
我想说最好的方法是将点投影到垂直于锥体方向的2D表面上。然后计算同一平面和点之间的正交距离。最后,您知道该高度处的圆锥宽度,因此您可以看到该点是否在该宽度之外。
#4
Let the vector from the point of origin to the specified point makes an angle A with the normal that runs through the center. If the angle A is less than the half angle of the cone it lies inside else outside.
让从原点到指定点的矢量与穿过中心的法线成一个角度A.如果角度A小于锥体的半角,则它位于其他外部。