Determine if a Line Touch or Cross a Shape


Author
Message
Volvick Derose
Volvick Derose
Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)
Group: Forum Members
Posts: 71, Visits: 1
Assume that I have line one or rectangle one in the drawing area, I want to know if it is possible to determine when a user draws a line or any shape if the shape touches or crosses line one or rectangle one.

is it possible to determine that?
Reply
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi,

You can check whether a given line segment intersects the bounds of a shape by using the following piece of code:

 

NShape shape = null;

NLineSegmentF lineSegment = new NLineSegmentF(0, 0, 100, 100);

if (lineSegment.IntersectsWith(shape.Bounds))

{

      // The line segment intersects the shape bounds

}

 

Similarly, you can test for rectangle intersections – just use the corresponding methods of the NRectangleF class.



Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search