View Full Version : Some VB Line control Work
ComputerNut
05-04-2004, 12:01 PM
Well im making a proggy which draws lines. I need to find out how to make the program find the Point Of Intersection between two intersecting lines (usind the VB Line Control). Any VB Masters who would know how to accomplish this? :)
Thanks in advance
I haven't used VB for ages, but I think your problem isn't related to VB, it's a math problem, you have 2 lines, and you want to calculate the point of intersection between them.
What info do you have about the line? 2 points? 1 point and slope? Or what?
ComputerNut
05-04-2004, 03:55 PM
well ive got the slope of the lines. and since im dealing with VB i know the X1 Y1, and X2 Y2 Coordinates of each line. btw, the slopes of the lines are stored in an array called slope(n) (n is the array #. every time i draw a line, its slope info is stored in its respective slope array spot. My theory is to have VB Trace the lines and once both traces hit the same number, that would be the intersect
doctorgonzo
05-04-2004, 04:45 PM
It's a math problem, so treat it as such. "Tracing" the lines or otherwise fiddling with graphical solutions will be far slower and cumbersome.
If (X1,Y1) is a point on a line of slope S1, and (X2,Y2) is a point on a line of slope S2, then the x-coordinate where they intersect is:
((S1*X1 + Y2) - (S2*X2 + Y1))/(S1-S2)
The y-coordinate can be found after you have the x-coordinate with:
S1*(X-X1)+Y1
ComputerNut
05-06-2004, 10:38 AM
Alright, ill try that. hopefully itll work with my code
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.