Results 1 to 3 of 3
- 12-05-2011, 01:48 AM #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:
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.jspJava 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); } }
Would greatly appreciate any help.Last edited by Trevor; 12-05-2011 at 02:05 AM.
- 12-05-2011, 01:51 AM #2
Re: Plotting The Intersection Of Two Vector Lines On A Graph
Would the plot consist of a number of lines drawn between points?is plot the two lines and where they intersect on a graph in a on screen window
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
- 12-05-2011, 02:00 AM #3
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
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.
Similar Threads
-
plotting graph
By dhruvaharsha in forum AWT / SwingReplies: 1Last Post: 02-06-2010, 07:04 PM -
Help in plotting graph
By javafanatic in forum New To JavaReplies: 20Last Post: 12-07-2009, 12:55 PM -
Help regarding 3D graph plotting...
By Megatron in forum New To JavaReplies: 1Last Post: 05-21-2009, 04:26 PM -
graph plotting
By sirine in forum New To JavaReplies: 5Last Post: 01-25-2009, 03:34 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks