我必须能够为飞行模拟的航路点设置随机位置。数学挑战很简单:
“在四边形内找到一个随机位置,该点位于任何位置的机会均等。”
视觉上是这样的:
ABCD 四边形示例如下:
答:[21417.78 37105.97]
乙:[38197.32 24009.74]
C:[1364.19 2455.54]
d:[1227.77 37378.81]
预先感谢您可以提供的任何帮助。 :-)
编辑
感谢大家的回复。我将在周末查看此问题,然后授予已接受的答案。顺便说一句,我应该提到四边形可以是凸的或凹的。抱歉。
将四边形分成两个三角形,然后使用这个优秀的答案 https://stackoverflow.com/questions/240778/random-points-inside-a-parallelogram/240898#240898快速找到其中一个随机点。
Update:
借用这个伟大的link http://mathworld.wolfram.com/TrianglePointPicking.html from Akusete https://stackoverflow.com/questions/3058150/how-to-find-a-random-point-in-a-quadrangle/3058274#3058274在三角形中随机选取一个点。
(from MathWorld - A Wolfram Web Resource: wolfram.com http://mathworld.wolfram.com/images/eps-gif/TrianglePointPicking_700.gif)
Given a triangle with one vertex at
the origin and the others at positions v1
and v2, pick
(from MathWorld - A Wolfram Web Resource: wolfram.com http://mathworld.wolfram.com/images/equations/TrianglePointPicking/NumberedEquation2.gif)
where A1
and A2 are uniform
variates in the interval [0,1] , which gives
points uniformly distributed in a
quadrilateral (left figure). The
points not in the triangle interior
can then either be discarded, or
transformed into the corresponding
point inside the triangle (right
figure).
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)