Compute the area of intersection between a circle and a triangle?

后端 未结 11 1083
礼貌的吻别
礼貌的吻别 2020-12-02 17:38

How does one compute the area of intersection between a triangle (specified as three (X,Y) pairs) and a circle (X,Y,R)? I\'ve done some searching to no avail. This is for

11条回答
  •  余生分开走
    2020-12-02 18:08

    Since your shapes are convex, you can use Monte Carlo area estimation.

    Draw a box around the circle and triangle.

    Choose random points in the box and keep a count of how many fall in the circle, and how many fall in both the circle and triangle.

    Area of Intersection ≅ Area of circle * # points in circle and triangle / # points in circle

    Stop choosing points when the estimated area doesn't change by more than a certain amount over a certain number of rounds, or just choose a fixed number of points based on the area of the box. The area estimate should converge pretty fast unless one of your shapes has very little area.

    Note: Here's how you determine if a point is in a triangle: Barycentric coordinates

提交回复
热议问题