# Some question about transformation

Printable View

• April 8th, 2014, 06:21 PM
jenny_wui
Some question about transformation
Attachment 32533

Hello, I think my previous postings were a bit confusing. I just wanted to clarify that in this posting. I have a plane and attached figure shows two positions of the plane, (a) no rotation and (b) with rotation where rotation axis is defined by ax + by + cz.

Now, the plane will rotate, but it will always look without rotation as shown in figure (a).

I think I need to play around with my glutReshape function which looks like follows:

Quote:

void glutReshape(int width, int height)
{

width = glutGet(GLUT_WINDOW_WIDTH);
height = glutGet(GLUT_WINDOW_HEIGHT);

if (width && height)
{
glViewport(0, 0, width, height);

nearDist = 150.0 / tan((kFovY / 2.0) * kPI / 180.0);
farDist = nearDist + 100.0;
aspect = (double) width / height;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(kFovY, aspect, 0.1, farDist+20);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

gluLookAt( 0.0, 0.0, (nearDist + 5.0), // camera/ eye
0.0, 0.0, 0.0, // center
0.0, 1.0, 0.0); // up vector

}

}
But I fail to correctly manipulate it. When rotation axis will move from (0, 0, 1) to (ax + by + bz), the eye/ camera will be changed from ( 0, 0, nearDist +5) to ( {(nearDist+5)*ax, (nearDist+ 5)*ay, (nearDist + 5)*az}. Is it right?

But what about the up vector? How will it change for this rotation? How can I calculate new up vector? Also what other parameters in my glutReshape function needs to be changed?

Please provide me some suggestion how can I fix this problem.

Thanks in advance.
• April 9th, 2014, 01:34 AM
D_Drmmr
Re: Some question about transformation
Quote:

Originally Posted by jenny_wui
I have a plane and attached figure shows two positions of the plane, (a) no rotation and (b) with rotation where rotation axis is defined by ax + by + cz.

That doesn't look like the rotation axis. When rotating about an axis, all point on the axis remain in the same location.
• April 9th, 2014, 07:29 PM
jenny_wui
Re: Some question about transformation
Hello, in the figure (b) the plane is rotated, but my eye is positioned in the same place i.e. (0, 0, 1) as in Figure (b). My goal is that the plane should look square like Figure (a) after rotation. I would like to know how that can be done. Thanks in advance.