Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Chaos Problems.

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Chaos Problems.

    The program runs, but the problem that I am having is converting the x,y Cartesian points to pixel points so I can print them out on the screen. The way the program is, it plots the points, but they are backwards, and the points need to fill the entire screen, however it only fills the upper left hand corner...
    public class convertxy
     
    	{
     
    	public static double[] convert(double[] xy) // Converts cartisian points to pixel points
     
    		{
     
    		double b1,b2,x1,y1,newx1,newy1,newx2,newy2,m1,m2,x,y,y11,x11;
     
    		int x2,x3,x4,y2,y3,y4;	
     
    		x11=-16;   //Upper left hand x
     
    		y11=14;    //Upper left hand y
     
    		x2=16;    //Lower right hand x
     
    		y2=-14;   //Lower right hand y
     
    		x3=0;     //Upper left pixel1
     
    		y3=0;     //Upper left pixel2
     
    		x4=639;   //Lower left pixel1
     
    		y4=559;   //Lower left pixel2
     
    		newx1=x3+x11;
     
    		newy1=y3+y11;
     
    		newx2=x4+x2;
     
    		newy2=y4+y2;
     
    		m1=(newx1/newy1);
     
    		m2=(newx2/newy2);
     
    		x=xy[0];
     
    		y=xy[1];
     
    		b1=(m1*(-14));
     
    		b2=(m2*(-16));
     
    		x1=(m1*x)+b1;
     
    		y1=(m2*y)+b2;
     
    		y1*=-1;	
     
    		xy[0]=x1;
     
    		xy[1]=y1;
     
    		System.out.println(xy[0]+" "+xy[1]);
     
    		return xy;
     
    		}
     
    	}
    This is the problem code section.^
    Thanks!
    Zmontoya94
    ChaosZip.zip
    Last edited by zmontoya94; April 6th, 2012 at 10:18 AM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Chaos Problems.

    Please post the code you are having problems.
    Is the problem with the y values? Java has y=0 ay the upper left vs the lower left.

    To fill the whole screen, you will need to map the x,y values to the x,y values shown on the screen.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Chaos Problems.

    When the image prints in the window, it is backwards, meaning the side that is on the left should be on the right. Which is probably a problem with the y values. What do you mean map the x,y values, sorry, I'm kinda new at this...

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Chaos Problems.

    map the x,y values,
    If your x,y values range from 10 to 50 and the screen size is 100, you need to "map" your values to the range of values of the screen. For example your 10 would be at the screen's 0 and your 50 would be at the screen's 100.

    Your description of the reversing of the image sounds like its the x axis problem, not the y values.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Chaos Problems.

    Quote Originally Posted by Norm View Post
    . For example your 10 would be at the screen's 0 and your 50 would be at the screen's 100.

    Your description of the reversing of the image sounds like its the x axis problem, not the y values.
    Ok, if that is what mapping is then it is done. I went ahead and took a screen shot of what is being painted on the screen.Untitled.jpg

    So that part on the left needs to be on the right, I will try and change something on the x values.

Similar Threads

  1. Problems with my HW
    By hws in forum Object Oriented Programming
    Replies: 14
    Last Post: December 30th, 2011, 12:18 PM
  2. [SOLVED] NIO Problems
    By bgroenks96 in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: November 12th, 2011, 06:26 PM
  3. [SOLVED] Have a few odd problems.
    By javapenguin in forum What's Wrong With My Code?
    Replies: 18
    Last Post: October 19th, 2010, 06:08 PM
  4. rmi problems
    By deepthought in forum Java SE APIs
    Replies: 7
    Last Post: September 7th, 2010, 07:25 PM
  5. How to compile and run java program?
    By ebalari56 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 27th, 2009, 09:33 PM