简体   繁体   English

in2d点之间的反射路径

[英]reflection paths between points in2d

Just wondering if there was a nice (already implemented/documented) algorithm to do the following 只是想知道是否有一个很好的(已经实现/记录)算法来执行以下操作
boo! 嘘! http://img697.imageshack.us/img697/7444/sdfhbsf.jpg http://img697.imageshack.us/img697/7444/sdfhbsf.jpg
Given any shape (without crossing edges) and two points inside that shape, compute all the paths between the two points such that all reflections are perfect reflections. 给定任何形状(没有交叉边缘)和该形状内的两个点,计算两个点之间的所有路径,使得所有反射都是完美的反射。 The path lengths should be limited to a certain length otherwise there are infinite solutions. 路径长度应限制在一定长度,否则会有无限的解决方案。 I'm not interested in just shooting out rays to try to guess how close I can get, I'm interested in algorithms that can do it perfectly. 我对拍摄光线不感兴趣,试图猜测我能接近多远,我对可以完美做到的算法感兴趣。 Search based, not guess/improvement based. 基于搜索,而不是基于猜测/改进。

I think you can do better than computing fans. 我认为你可以比计算粉丝做得更好。 Call your points A and B . 拨打你的积分AB You want to find paths of reflections from A to B . 您想要找到从AB的反射路径。

Start off by reflecting A in an edge, and call the reflection A1 . 首先在边缘反射A ,然后调用反射A1 Can you draw a line from A1 to B that only hits that edge? 你能画一条从A1B的线,只能击中那条边吗? If yes, that means you have a path from A to B that reflects on the edge. 如果是,那意味着您有一条从AB的路径,它反映在边缘上。 Do this for all the edges and you'll get all the single reflection paths that exist. 对所有边缘执行此操作,您将获得所有存在的单个反射路径。 It should be easy to construct these paths using the properties of reflections. 使用反射属性构建这些路径应该很容易。 Along the way, you need to check that the paths are legal, ie they do not cross other edges. 在此过程中,您需要检查路径是否合法,即它们不会跨越其他边缘。

You can continue to find paths consisting of two reflections by reflecting all the first generation reflections of A in all the edges, and checking to see whether a line can be drawn from those points through the reflecting edge to B . 您可以通过反映A在所有边缘的所有第一代反射,并检查是否可以从这些点通过反射边缘到B来绘制由两个反射组成的路径。 Keep on doing this search until the distance of the reflected points from B exceeds a threshold. 继续进行此搜索,直到B的反射点距离超过阈值。

I hope this makes sense. 我希望这是有道理的。 It should be easier than chasing fans and dealing with their breakups, even though you're still going to have to do some work. 它应该比追逐粉丝和处理他们的分手更容易,即使你仍然需要做一些工作。

By the way, this is a corner of a well studied field of billiards on tables of various geometries. 顺便说一下,这是一个在各种几何形状的桌子上研究良好的台球领域的一个角落。 Of course, a billiard ball bounces off the side of a table the same way light bounces off a mirror, so this is just another way of thinking of reflections. 当然,台球从桌子的侧面反弹,就像光从镜子反射一样,所以这只是思考反射的另一种方式。 You can delve into this with search terms like polygonal billiards unfolding illumination , although the mathematicians tend to dwell on finding cases where there are no pool shots between two points on a polygonal table, as opposed to directly solving the problem you've posed. 您可以使用polygonal billiards unfolding illumination等搜索术语来深入研究,尽管数学家倾向于寻找多边形桌子上两点之间没有池射击的情况,而不是直接解决您提出的问题。

Think not in terms of rays but fans. 不要考虑光线而是粉丝。 A fan would be all the rays emanating from one point and hitting a wall. 风扇将是从一个点发出并撞击墙壁的所有光线。 You can then check if the fan contains the second point and if it does you can determine which ray hits it. 然后,您可以检查风扇是否包含第二个点,如果是,您可以确定哪个光线击中了它。 Once a fan hits a wall, you can compute the reflected fan by transposing it's origin onto the outside of the wall - by doing this all fans are basically triangle shaped. 一旦风扇撞到墙壁,你可以通过将它的原点转移到墙的外面来计算反射的风扇 - 通过这样做,所有风扇基本上都是三角形的。 There are some complications when a fan partially hits a wall and has to be broken into pieces to continue. 当风扇部分撞到墙壁并且必须被分成碎片以继续时,存在一些复杂性。 Anyway, this tree of reflected fans can be traversed breadth first or depth first since you're limiting the total distance. 无论如何,由于你限制了总距离,所以这个反射扇的树可以先穿过宽度或先穿过深度。

You may also want to look into radiosity methods, which is probably similar to what I've just described, but is usually done in 3d. 您可能还想查看光能传递方法,这可能类似于我刚才描述的方法,但通常在3d中完成。

I do not know of any existing solutions for such a problem. 我不知道这个问题的任何现有解决方案。 Good luck to you if you find one, but incase you don't the first step to a complete but exponential (with regard to the line count) would be to break it into two parts: 如果你找到一个,祝你好运,但是如果不是第一步完成但是指数(关于行数)会将它分成两部分:

  1. Given an ordered subset of walls A,B,C and points P1, P2, calculate if a route is possible (either no solutions or a single unique solution). 给定墙A,B,C和点P1,P2的有序子集,计算路线是否可行(无解决方案或单个唯一解决方案)。

  2. Then generate permutations of your walls until you exceed whatever limit you had in mind. 然后生成墙壁的排列,直到超出你的想法。

The first part can be solved by a simple set of equations to find the necessary angles for each ray bounce. 第一部分可以通过一组简单的方程来求解,以找到每次射线反弹的必要角度。 Then checking each line against existing lines for collisions would tell you if the path is possible. 然后针对现有线路检查每条线路是否存在冲突将告诉您路径是否可行。

The parameters to the system of equations would be 方程组的参数是

angle_1 = normal of line A with P1
angle_2 = normal of line B with intersection of line A
angle_3 = normal of line C with ...
angle_n = normal of line N-1 with P2

Each parameter is bounded by the constraints to hit the next line, which may not be linear (I have not checked). 每个参数都受限于下一行的约束,这可能不是线性的(我没有检查过)。 If they are not then you would probably have to pick suitable numerical non-linear solvers. 如果它们不是那么你可能不得不选择合适的数字非线性求解器。

In response to brainjam 回应脑筋急转弯
You still need wedges.... 你还需要楔子....
alt text http://img72.imageshack.us/img72/6959/ssdgk.jpg alt text http://img72.imageshack.us/img72/6959/ssdgk.jpg
In this situation, how would you know not to do the second reflection? 在这种情况下,你怎么知道不做第二次反思? How do you know what walls make sense to reflect over? 你怎么知道哪些墙壁有意义反映过来?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM