Lines crossing

G

Guest

I'm drawing points and lines in a picturebox control in visual basic .Net,
and i need to know the point() where those lines "cross" each other. That
would be easy if the lines where only vertical and horizontal because i could
try to find the pixels that would be used between two point to draw the lines
and see if there is a common pixel for those two lines but if the line(s) is
diagonal i can't determine the point where the lines meet each other
Is there anyway in vb .net to find the point where two lines meet each other?

\
\ /
\/
/\
/ \
/ \
\
 
S

Stanav

Ricardo,
Try to run a scanline down in your picturebox and check how many pixels are
used in each scanline.
If the number of pixels used in the curent scanline drops to 1 (from 2 on
the last scanline) then you know this is where the 2 lines cross. Just an
idea.
Stanav.
 
G

Guest

Get a math book and look up the formula for finding the intersection of two
lines in two dimensional space. You have the start coord and end coord for
both lines since you have drawn them so it should be easy to find the
intersection of two lines.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top