确定光子是否会与 3D 空间中的多边形碰撞以及在何处碰撞

发布于 2024-09-03 22:10:19 字数 512 浏览 9 评论 0原文

问题很简单:

1) 我们有一个光子从点 1 (x,y,z) 传播到点 2 (x,y,z),这两个点都可以位于 3D 空间中的任何位置。

2) 我们有一个多边形,它既在 x 轴和/或 y 轴上随机旋转,又位于 3D 空间中的任何位置。

3) 我们想要找到:a) 光子是否会与多边形碰撞;b) 如果确实会碰撞,那么 (x,y,z) 会在哪里?

问题的图像: http: //dl.dropbox.com/u/3150177/Programming/3D/Math/Photon%20Path/Photon%20Path.png

这样做的目的是计算光子的路径应如何从交互中改变)与多边形。

我现在正在阅读这个主题,但我想知道是否有人可以给我一个良好的开端。提前致谢。

The problem is straight forward:

1) We have a photon traveling from Point 1 (x,y,z) to Point 2 (x,y,z), both of which could be located anywhere in 3D space.

2) We have a polygon that is both rotated randomly on the x-axis and/or y-axis and also located anywhere in 3D space.

3) We want to find: a) if the photon will collide with the polygon at all and b) if it does where will that be (x,y,z)?

An image of the problem: http://dl.dropbox.com/u/3150177/Programming/3D/Math/Photon%20Path/Photon%20Path.png

The aim of this is to calculate how the photon's path should be altered from an interaction(s) with the polygon(s).

I am reading up on this subject now but I was wondering if anyone could give me a head start. Thanks in advance.

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

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

发布评论

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

评论(5

夜声 2024-09-10 22:10:19

听起来您正在寻找射线/多边形相交测试。

我不记得细节了,但我想你把它分成了两部分。首先,找到多边形平面上光线相交的点。这可以通过简单的射线/平面相交测试得到。其次使用多边形平面上的坐标系来测试交点是否位于多边形内。这可以通过多边形内的点测试得到。

Sounds like you are looking for a ray/polygon intersection test.

I can't remember the details but I imagine you split it into two parts. First you find the point on the polygon's plane that the ray intersects at. This can be got from a simple ray/plane intersection test. Secondly use a co-ordinate system on the polygon's plane to test whether the intersection point lies within the polygon. This can be got from a point-in-polygon test.

巨坚强 2024-09-10 22:10:19

总体概述:

1) 线段平面相交: 确定连接点 1 和 2 的线段是否与包含多边形的平面相交。如果没有,那么它永远不会与多边形相交,你就完成了。

2)求交点:确定线段与平面的交点。这将提供您问题中 3-b 中所需的信息。将此点称为 Q

3) 确定 Q 是否在多边形内部: 确定这一点的一种方法是 < a href="http://ozviz.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/" rel="nofollow noreferrer">此处,但精心设计的 Google 搜索可能会导致其他结果。您可以针对您期望的不同类型的多边形(即凸多边形)或包含多边形的平面是否轴向对齐(即坐标系的轴之一垂直于包含多边形的平面)进行优化。

假设:所有多边形的点都是共面的。

General overview:

1) Segment-Plane Intersection: Determine if the line segment connecting points 1 and 2 intersects the plane containing the polygon. If it doesn't, then it will never intersect the polygon, and you're done.

2) Find Point of Intersection: Determine the point at which the line segment and plane intersect. This will provide the information you want in 3-b in your question. Call this point Q

3) Determine if Q is interior to the polygon: One method of determining this is here, but a well crafted Google search will likely result in others. You can optimize for different types of polygons you expect (i.e. convex) or if the plane containing the polygon is axially aligned (i.e. one of the axes for your coordinate system is normal to the plane containing the polygon).

Assumption: All of the polygon's points are co-planar.

来世叙缘 2024-09-10 22:10:19

你正在做光线追踪。最有效的方法是将多边形分解为三角形并使用 Moeller 射线三角形测试。或者也许是沃尔德测试。还有一些变体使用顶点信息之外的额外存储数据,如果您对同一个三角形执行多条光线,速度会更快。谷歌提供了如此多的结果,我还没有选择一个“最好”的结果放在这里。

You're doing ray tracing. Most efficient is to break the polygon into triangles and use the Moeller ray-triangle test. Or perhaps the Wald test. There are also variants that use extra stored data beyond just the vertex information which can be even faster if you're doing multiple rays against the same triangle. Google provides so many results, I haven't selected a "best" one to put here.

绅刃 2024-09-10 22:10:19

光子以向量 v = p2 - p1 从 p1 开始行进,创建这条线:

p1 + v * a 

要查明光子是否与多边形碰撞,您必须找到 a 的值:

p1 + v * a = polygon

例如:

p1 is (15, 4, 5)
p2 is (10, 1, 3) 
and polygon is a 10x10 square: (-5...5, -5...5, 0)

v = p2 - p1 = (-5, -3, -2)

p1 + v * a = pol 使得:

p1.x + v.x * a = pol.x
p1.y + v.y * a = pol.y
p1.z + v.z * a = pol.z

a = (pol.z - p1.z) / v.z = (0 - 15) / -2 = 7.5
pol.x = p1.x + v.x * a = 15 + -5 * 7.5 = -22.5
pol.y = p1.y + v.y * a = 10 + -3 * 7.5 = -12.5

-22.5 不在-5 和5 之间,-12.5 不在-5 和5 之间,因此光子不会与多边形碰撞。

我已经有一段时间没有这样做了,所以我可能犯了一些错误。我使用 pol.z = 0 的事实来计算 a。您可能需要旋转多边形以与一个轴对齐,只要您也绕多边形的中心旋转 p1 即可。

The photon is traveling with vector v = p2 - p1 starting at p1, creating this line:

p1 + v * a 

To find out if the photon collides with the polygon you have to find a value for a for:

p1 + v * a = polygon

For example:

p1 is (15, 4, 5)
p2 is (10, 1, 3) 
and polygon is a 10x10 square: (-5...5, -5...5, 0)

v = p2 - p1 = (-5, -3, -2)

p1 + v * a = pol makes:

p1.x + v.x * a = pol.x
p1.y + v.y * a = pol.y
p1.z + v.z * a = pol.z

a = (pol.z - p1.z) / v.z = (0 - 15) / -2 = 7.5
pol.x = p1.x + v.x * a = 15 + -5 * 7.5 = -22.5
pol.y = p1.y + v.y * a = 10 + -3 * 7.5 = -12.5

The -22.5 is not between -5 and 5 and -12.5 is not between -5 and 5, so the photon does not collide with the polygon.

It's been a while since I've done this so I may have made some mistakes. I used the fact that pol.z = 0 to calculate a. You may have to rotate the polygon to line up with one axis, as long as you rotate p1 around the polygon's center as well.

缘字诀 2024-09-10 22:10:19

射线/三角形相交很好理解并且很容易。不过,轮换更难。

也许您可以使用 旋转矩阵 变换三角形的顶点,然后使用简单的射线/三角形相交?

Ray / triangle intersections are well understood and quite easy. The rotations are harder, though.

Perhaps you could transform the triangle's vertices using a rotation matrix and then use a simple ray / triangle intersection?

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