Profile Picture

Determine if a Line Touch or Cross a Shape

Posted By Volvick Derose 13 Years Ago
Author
Message
Volvick Derose
Posted 13 Years Ago
View Quick Profile
Forum Guru

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
Last Active: 12 Years Ago
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?

Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 2 days ago @ 1:54 AM
Posts: 3,054, Visits: 4,009

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



Volvick Derose
Posted 13 Years Ago
View Quick Profile
Forum Guru

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
Last Active: 12 Years Ago
Posts: 71, Visits: 1
I would like that to be hooked to an event. For instance, assume that the user draws a rectangle first in the drawing view, then when the user draws a line in the drawing view, if the line crosses the rectangle, then I fire a message. I did not find any event that I can use to check when a specific shape is drawn on the drawing view. The only thing I can find is NodeBoundsChanging



Similar Topics


Reading This Topic