|
Author |
Topic: actual x,y (Read 452 times) |
|
Ethan
|
actual x,y
« on: Sep 13th, 2003, 12:00am » |
|
Hello I'm new here :-D Here is my first proce55ing piece. (hold down the mouse for a variation) My question: Is there a way to find out the actual x,y of a point after I have applied transformations? so I go: translate(50,50); rotateX(PI/3.0); point(15,15); where does that point actually get rendered?
|
« Last Edit: Sep 13th, 2003, 12:03am by Ethan » |
|
|
|
|
Jerronimo
|
Re: actual x,y
« Reply #1 on: Sep 13th, 2003, 3:14am » |
|
That is really neat. It reminds me of playing with magnets and iron filings.
|
|
|
|
benelek
|
Re: actual x,y
« Reply #2 on: Sep 13th, 2003, 8:37am » |
|
objectX(x,y,z), objectY(x,y,z), objectZ(x,y,z) should do the trick (for coordinates in the original untransformed space). but screenX etc will give you the coordinates as rendered on the x/y pixel array.
|
|
|
|
Ethan
|
Re: actual x,y
« Reply #3 on: Sep 15th, 2003, 10:18pm » |
|
thanks Jerronimo, and benelek, I hadn't even looked at screenX() in the documentation.. my bad. I am having some trouble with it though.. I have this in my loop: Code: float sx = screenX(x,y,z); float sy = screenY(x,y,z); println("screenX(" + x + "," + y + "," + z + ") = " + sx); |
| and the output is: Code: screenX(-325,-540,-880) = 125.0 screenX(-275,-540,-880) = 125.0 screenX(-225,-540,-880) = 125.0 screenX(-175,-540,-880) = 125.0 screenX(-125,-540,-880) = 125.0 screenX(-75,-540,-880) = 125.0 screenX(-25,-540,-880) = 125.0 screenX(25,-540,-880) = 125.0 screenX(75,-540,-880) = 125.0 |
| I'm not sure why I keep getting 125.0 What is objectX() ? It's not in the documentation huh? when I change screenX() to objectX() I get zero back instead of 125.0;
|
|
|
|
benelek
|
Re: actual x,y
« Reply #4 on: Sep 16th, 2003, 6:10pm » |
|
objectX gives you coordinates in 3d space. screenX gives you the location of that point on the screen grid, ie the projection to the camera plane. but both provide references to a point's position within the non-transformed matrix. i haven't seen the rest of your code, but would you have rotated the matrix by PI/4 or 90 degrees? since you've kept the y value constant in your points, that might explain it... try varying the y value in your example, and see if you get different screenX's.
|
|
|
|
|