# Thread: Plotting The Intersection Of Two Vector Lines On A Graph

1. Member
Join Date
Dec 2011
Posts
7
Rep Power
0

## Plotting The Intersection Of Two Vector Lines On A Graph

I have write a little program in java that finds where two vector line equations intersect:
Java Code:
```public class vector line intersect {
public static void main(String[] args){

//position vectors line1(x = 0, y = 100) line2 (x = 100, y = 200)
int pv[]={0, 100, 100, 200};
// direction vectors line1(1, 2) line2 (2, 5)
int dv[]={1, 2, 2, 5};

//solving simultaneous equations (systems of equations)
int λ = (dv[2] * (pv[3] - pv[2]) - dv[3] * (pv[1] - pv[0])) / (dv[2] * dv[1] - dv[0] * dv[3]);
int µ = (dv[0] * (pv[2] - pv[3]) - dv[1] * (pv[0] - pv[1])) / (dv[0] * dv[3] - dv[2] * dv[1]);
System.out.println(x);
System.out.println(y);
}

}```
Now what I would like to do next is plot the two lines and where they intersect on a graph in a on screen window like the following applet: http://www.waldomaths.com/Simul1NLW.jsp
Would greatly appreciate any help.
Last edited by Trevor; 12-05-2011 at 03:05 AM.

2. ## Re: Plotting The Intersection Of Two Vector Lines On A Graph

is plot the two lines and where they intersect on a graph in a on screen window
Would the plot consist of a number of lines drawn between points?
The Graphics class has methods to draw lines.
Create a GUI with frame and panel. Override the paintComponent method in the panel and add the necessary drawing methods to draw the lines.
You probably need to read the java tutorial on how to do that. I don't have the exact link you want but here are some starting places:
The Java™ Tutorials
The Really Big Index

3. Moderator
Join Date
Feb 2009
Location
New Zealand
Posts
4,565
Rep Power
12

## Re: Plotting The Intersection Of Two Vector Lines On A Graph

I've deleted the accidental double post of this.

There's quite a lot of work, but the starting point might well be the description of Graphical User Interfaces in Oracle's Tutorial.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•