
January 27th, 2010, 07:48 AM
#1
System.Drawing.Graphics and intersection lines point detection
Hello,
I'm actually playing around with System.Drawing.Graphics.
I'm try to accomplish the following, but I'm unable:
I want to draw lines using Graphics.DrawLine method (let´s say the lines color are light gray).
I want also that, when a line intersect with other line, the intersection point to be grayer that the two lines itself. Maybe, even draw the intersection point in other color.
I've been trying with region, paths, compositing modes, but I'm unable to acomplish my goal.
żAny suggestions about this?
Thankyou, regards...

January 27th, 2010, 12:05 PM
#2
Re: System.Drawing.Graphics and intersection lines point detection
Are these true lines? If so, you can simply find the function of each line and when y1=y2 you have an intersection point. This is also possible with nonlinear equations, but it gets more tricky.
EDIT:
To expand on that a bit, if you have two lines defined by the following functions:
Code:
y = 2x + 4
y = x + 1
You may then find the point of intersection by substituting for y and solving for x:
Code:
2x + 4 = x + 1
2x = x  3
x = 3
So, at x=3 we know we have a point of intersection. We can prove this by plugging in 3 for x in the two equations and verifying that we get the same result:
Code:
y = 2(3) + 4
y = 6 + 4
y = 2
y = 3 + 1
y = 2
The two lines intersect at (3,2).
Last edited by BigEd781; January 28th, 2010 at 12:25 PM.

January 28th, 2010, 12:23 PM
#3
Re: System.Drawing.Graphics and intersection lines point detection
Just gonna bump this for the OP since I have added an example.
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.
Featured
