Check if a point is in a rotated rectangle (C#)

前端 未结 7 1466
囚心锁ツ
囚心锁ツ 2021-01-07 22:20

I have a program in C# (Windows Forms) which draws some rectangles on a picturebox. They can be drawn at an angle too (rotated).

I know each of the rectangles\' star

7条回答
  •  醉梦人生
    2021-01-07 22:51

    Is it possible to apply the same rotation applied to the rectangle to the point in reverse?

    For example, Rectangle A is rotated 45 degrees clockwise from its origin (upper left corner), you would then just rotate point B around the same origin 45 degrees COUNTER clockwise, then check to see if it falls within Rectangle A pre-rotation

提交回复
热议问题