二维几何:如何检查点是否在角度内

发布于 2024-07-29 00:54:25 字数 171 浏览 4 评论 0原文

我在 2D 中遇到以下几何问题:

我有一个点,从该点投射无限角度(2D 锥体),该角度由方向和角度给出。 (该点和方向形成一个向量,并且角度的每一侧一半形成 2D 圆锥体)

现在我想检查 2D 中的另一个点是否位于该圆锥体内部或外部。

如何才能实现这一目标? 谢谢!

i have the following geometrical issue in 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)

now i want to check if another point in 2D is inside this cone or outside.

how can this be achieved?
thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

初见终念 2024-08-05 00:54:25

计算从圆锥体中心到查询点的向量。 将向量标准化为长度 1,取圆锥体的中心向量并将其标准化为长度 1。
现在计算向量之间的点积。 两个归一化向量之间的点积是它们之间角度的余弦。 取点积的反余弦(在大多数语言中为acos),您就可以得到角度。 将此角度与圆锥角(描述中的半角)进行比较。 如果它较低,则问题点位于圆锥体内部。

这适用于 2D 和 3D。

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.

This works in 2D and 3D.

茶色山野 2024-08-05 00:54:25

使用方向的 arctg 计算方向的角度。 从检查点中减去原点。 计算它的角度(再次通过标准化向量的 arctg),并检查它是否位于角度边界内。

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.

埋葬我深情 2024-08-05 00:54:25

我想说最好的方法是将点投影到垂直于锥体方向的二维表面上。 然后计算同一平面和该点之间的正交距离。 最后,您知道圆锥体在该高度处的宽度,因此您可以查看该点是否在该宽度之外。

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.

书信已泛黄 2024-08-05 00:54:25

让从原点到指定点的向量与穿过中心的法线形成角度 A。 如果角 A 小于圆锥的半角,则圆锥位于内侧,否则位于外侧。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文