Solved

The tale of two lines

Posted on 2001-08-07
7
140 Views
Last Modified: 2010-05-02
If I have two lines on a graphic, and for each line I have two coordiantes.

How can I get the coordinates of the intersection between the two in the most efficiant way possible ?
0
Comment
Question by:Pennywisdom
7 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 100 total points
ID: 6361318
0
 
LVL 3

Expert Comment

by:jrspano
ID: 6361321
0
 
LVL 3

Expert Comment

by:DennisL
ID: 6361466
Formula for a Line
x = ay + b

line 1:
x = 3y + 1

line 2:
x = 2y + 3

therefore:

3y + 1 = 2y + 3

((3y - 2y) = (3 - 1))

y = 2

x = 3(2) + 1
x = 7

The coordinates are x = 7, y = 2

The number beside the y controls the pitch.  And the other number controls the height above the x-axis (or y?).  

In terms of programming, you'll probably be able to do it all in one or two lines.  All you really need is the a and b and do some formula against it to get y, then get x.
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 5

Expert Comment

by:jklmn
ID: 6361568
Hi Pennywisdom,

If your lines are controls, try this:

Private Sub Command1_Click()
k1 = (Line1.Y2 - Line1.Y1) / (Line1.X2 - Line1.X1)
c1 = Line1.Y1 - k1 * Line1.X1
k2 = (Line2.Y2 - Line2.Y1) / (Line2.X2 - Line2.X1)
c2 = Line2.Y1 - k2 * Line2.X1
x = (c2 - c1) / (k1 - k2)
y = k1 * x + c1
Print x, y
End Sub
0
 
LVL 3

Expert Comment

by:DennisL
ID: 6361588
Formula for a Line
x = ay + b

line 1:
x = 3y + 1

line 2:
x = 2y + 3

therefore:

3y + 1 = 2y + 3

((3y - 2y) = (3 - 1))

y = 2

x = 3(2) + 1
x = 7

The coordinates are x = 7, y = 2

The number beside the y controls the pitch.  And the other number controls the height above the x-axis (or y?).  

In terms of programming, you'll probably be able to do it all in one or two lines.  All you really need is the a and b and do some formula against it to get y, then get x.
0
 

Author Comment

by:Pennywisdom
ID: 6365156
Thanks alot thats exacly what I needed
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6365276
no prob, glad to help!
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sending a email via excel using vba 6 82
VBA: Select SQL query based on a config Sheet v2 11 44
Hide vba in gp 7 95
VB6 - Convert HH:MM into Decimal 8 54
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question