# Chaos Problems.

• April 6th, 2012, 10:01 AM
zmontoya94
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...
Code :

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
Attachment 1152
• April 6th, 2012, 11:08 AM
Norm
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.
• April 6th, 2012, 11:25 AM
zmontoya94
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...
• April 6th, 2012, 11:29 AM
Norm
Re: Chaos Problems.
Quote:

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.
• April 6th, 2012, 11:40 AM
zmontoya94
Re: Chaos Problems.
Quote:

Originally Posted by Norm
. 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.Attachment 1153

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