Hello all,:wave:
how to know if two rectangles intersect:sick:
i know for polygon center, length, width and angle
i want to fast algorithm for visual basic 2008
very thanks
Printable View
Hello all,:wave:
how to know if two rectangles intersect:sick:
i know for polygon center, length, width and angle
i want to fast algorithm for visual basic 2008
very thanks
First you mention rectangle, then polygon. Which is it? For rectangles, use the Rectangles IntersectsWith method.
My rectangle is rotating.
I have two rotating rectangle and i know width, height, center and angle for each rectangle.
how to know if two rectangles intersect?
The IntersectsWith Method works with rotating rectangle?
IntersectsWith wont work with that no, simply because the Rectangle structure that exposes that method can not represent a rotated rectangle.
You'll have to implement one of the many polygon clipping algorithms available...here are a few links that might get you going:
http://www.codeguru.com/cpp/misc/mis...icle.php/c8965
http://clippoly.sourceforge.net/appe...ppendices.html
I also found this library that might be worth looking at.
ok Atheist nice link.
The function is ok, but I have a small problem.
My rectangle i know width, height, center and angle for each rectangle.
how to find the angle of the rectangle?
This should work, if you put your polygons into two GraphicsPath objects:
(just make sure they both have the same origin)
vb Code:
Public Shared Function PolygonsInterset(ByVal poly1 As System.Drawing.Drawing2D.GraphicsPath, ByVal poly2 As System.Drawing.Drawing2D.GraphicsPath) As Boolean poly1.Flatten() poly2.Flatten() For Each pt As System.Drawing.PointF In poly1.PathPoints If poly2.IsVisible(pt) Then Return True End If Next Return False End Function