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

1. ## 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;

y=xy;

b1=(m1*(-14));

b2=(m2*(-16));

x1=(m1*x)+b1;

y1=(m2*y)+b2;

y1*=-1;

xy=x1;

xy=y1;

System.out.println(xy+" "+xy);

return xy;

}

}```
This is the problem code section.^
Thanks!
Zmontoya94
ChaosZip.zip  Reply With Quote

3. ## 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.  Reply With Quote

4. ## 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...  Reply With Quote

5. ## 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.  Reply With Quote

6. ## Re: Chaos Problems. 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.Untitled.jpg

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