How to find a random point in a quadrangle?

后端 未结 9 1696
忘掉有多难
忘掉有多难 2021-02-08 12:53

I have to be able to set a random location for a waypoint for a flight sim. The maths challenge is straightforward:

\"To find a single random location within a quadrangl

9条回答
  •  忘掉有多难
    2021-02-08 13:24

    So, this time tackling how to figure out if a point is within the quad:

    The four edges can be expressed as lines in y = mx + b form. Check if the point is above or below each of the four lines, and taken together you can figure out if it's inside or outside.

提交回复
热议问题