View Full Version : RiRotate problem

 shazhixin03-15-2006, 08:20 AMI am reading the < renderman companion>. In the listing 2.4 example on the book, I am confused by the RiRotate. the code is : void UnitCube(void) { static RtPoint square[4] = { {.5,.5,.5}, {-.5,.5,.5}, {-.5,-.5,.5}, {.5,-.5,.5} }; /* far square */ RiPolygon((RtInt) 4, RI_P, (RtPointer) square, RI_NULL); /* right face */ RiRotate(90.0, 0.0, 1.0, 0.0); RiPolygon((RtInt) 4, RI_P, (RtPointer) square, RI_NULL); /* near face */ RiRotate(90.0, 0.0, 1.0, 0.0); RiPolygon((RtInt) 4, RI_P, (RtPointer) square, RI_NULL); /* left face */ RiRotate(90.0, 0.0, 1.0, 0.0); RiPolygon((RtInt) 4, RI_P, (RtPointer) square, RI_NULL); /* bottom face */ ??? RiRotate(90.0, 1.0, 0.0, 0.0); RiPolygon((RtInt) 4, RI_P, (RtPointer) square, RI_NULL); /* top face */ RiRotate(180.0, 1.0, 0.0, 0.0); RiPolygon((RtInt) 4, RI_P, (RtPointer) square, RI_NULL); } But I can not figure out how the bottom face is made by rotating the left face. The book said "It seems at first that the fifth square would be rotated in y by 270 degrees, then spun in x by 90, leaving it as the left face , in the same position as the fourth". I also think so. But the author continued : "But the last transformation declared is performed first. The rotation aboout X first brings square to the bottom of the cube, and the other rotations leave it spinning, essentially unchanged. The net effect of the two x-rotations applied to the last square is to rotate it by 270 degrees before the y-rotations." I do not understand that. please help me. thank you very much.
fxjeane
03-16-2006, 05:09 PM
Thats just the order in which renderman executes transformations. Here is an excerpt from Malcolm Kessons RenderMan course

Although the renderer reads the transformations in order in which they appear it postpones applying them until an object is declared, at which time it back-tracks and uses the transformations from last to first, like bullets in a magazine of a gun, the last one loaded is the first to be shot.

and here is a link to a discussion that might help

I hope that helps

DR

shazhixin
03-17-2006, 01:11 AM
Thank you. I read the rman_booklet and figure out now. and the rendermanacademy and siggraph have a lot of papers to learn.

neuromancer1978
03-17-2006, 02:21 AM
Thats just the order in which renderman executes transformations. Here is an excerpt from Malcolm Kessons RenderMan course

and here is a link to a discussion that might help

I hope that helps

DR

Hey Rudy! Didn't know you frequented here. Cool as hell!

mbaas
03-17-2006, 05:06 PM
As was mentioned before (even in your own posting ;) the transformations are applied in reverse order (so that you can create transformation hierarchies). But also note that in this case you always have to apply the transformations with respect to the global coordinate frame (i.e. you always rotate about the global axes).

If you find it confusing to think in "reverse order", you can also think in "forward order" if you apply the transformations with respect to the local coordinate system. In this case, you can actually read your transformations from top to bottom but you must not forget that each rotate command also rotates the coordinate system which is then used for the next command. In your example, the bottom face is first rotated three times around Y (note that this axis remains the same after each rotation) and after that it is rotated around its local X axis (which at this point is aligned with the global Z axis). Of course, the resulting position and orientation is the same as when you first rotate it about the global X axis and then three times about the global Y axis (which is what was already explained).

It's just two different ways of seeing transformations, you can chose yourself which one you prefer.

- Matthias -

CGTalk Moderation
03-17-2006, 05:06 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.

1