Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 05-04-2004, 11:01 AM   #1
Its the Dark Side!
 
ComputerNut's Avatar
 
Join Date: Jan 2004
Location: Kitchener, Ontario, Canada
Posts: 1,111
Send a message via MSN to ComputerNut
Post Some VB Line control Work

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
__________________
CN
My Rig: "Dark Lord"
Asus P5B - Intel Core 2 Duo E6400 - 1GB DDR2 667 RAM - Seagate SATAII 80GB HDD - Seagate SATAII 250GB HDD - Lite-On DVD -/+ RW Drive - nVidia GeForce 7600 GS - ATi TV Wonder VE

ComputerNut is offline   Reply With Quote
Old 05-04-2004, 11:52 AM   #2
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
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?
aym is offline   Reply With Quote
Old 05-04-2004, 02:55 PM   #3
Its the Dark Side!
 
ComputerNut's Avatar
 
Join Date: Jan 2004
Location: Kitchener, Ontario, Canada
Posts: 1,111
Send a message via MSN to ComputerNut
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
ComputerNut is offline   Reply With Quote
Old 05-04-2004, 03:45 PM   #4
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
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
doctorgonzo is offline   Reply With Quote
Old 05-06-2004, 09:38 AM   #5
Its the Dark Side!
 
ComputerNut's Avatar
 
Join Date: Jan 2004
Location: Kitchener, Ontario, Canada
Posts: 1,111
Send a message via MSN to ComputerNut
Alright, ill try that. hopefully itll work with my code
ComputerNut is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:54 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2