CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2013
    Posts
    31

    Some question about transformation

    Name:  plane.jpg
Views: 697
Size:  11.5 KB

    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:

    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.

  2. #2
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,042

    Re: Some question about transformation

    Quote Originally Posted by jenny_wui View Post
    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.
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

  3. #3
    Join Date
    Mar 2013
    Posts
    31

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured