Results 1 to 3 of 3
  1. #1
    Trevor is offline Member
    Join Date
    Dec 2011
    Posts
    7
    Rep Power
    0

    Default 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 02:05 AM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,274
    Rep Power
    25

    Default 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. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default 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

  1. plotting graph
    By dhruvaharsha in forum AWT / Swing
    Replies: 1
    Last Post: 02-06-2010, 07:04 PM
  2. Help in plotting graph
    By javafanatic in forum New To Java
    Replies: 20
    Last Post: 12-07-2009, 12:55 PM
  3. Help regarding 3D graph plotting...
    By Megatron in forum New To Java
    Replies: 1
    Last Post: 05-21-2009, 04:26 PM
  4. graph plotting
    By sirine in forum New To Java
    Replies: 5
    Last Post: 01-25-2009, 03:34 PM

Posting Permissions

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