Finding the overlapping area of two rectangles (in C#)

后端 未结 2 586
醉酒成梦
醉酒成梦 2020-12-16 00:23

Edit:

Simple code I used to solve the problem in case anyone is interested (thanks to Fredrik):

    int windowOverlap(Rectangle rect1, Rectangle rect         


        
相关标签:
2条回答
  • 2020-12-16 00:45

    Maybe I misinterpret your question, but doesn't the Rectangle.Intersect method do the job? It returns the intersecting area, and then you can easily calculate the area of it.

    0 讨论(0)
  • 2020-12-16 00:48

    Sounds like basic Collision Detection. Have you looked at this page on Wikipedia?

    Mike

    edit: Fredrik make his response at the same time I made this one, his answer got my upvote ( :

    0 讨论(0)
提交回复
热议问题