How to determine whether a point (X,Y) is contained within an arc section of a circle (i.e. a Pie slice)?

前端 未结 4 728
面向向阳花
面向向阳花 2020-12-02 19:03

Imagine a circle. Imagine a pie. Imagine trying to return a bool that determines whether the provided parameters of X, Y are contained within one of those pie pieces.

<
4条回答
  •  一向
    一向 (楼主)
    2020-12-02 19:50

    Convert X,Y to polar coordinates using this:

    Angle = arctan(y/x); Radius = sqrt(x * x + y * y);

    Then Angle must be between StartingAngle and EndingAngle, and Radius between 0 and your Radius.

提交回复
热议问题