Re: centr of rotation/centering



On Jul 21, 7:07 am, Luc Moulinier <mou...@xxxxxxxxxxxxxxxxxx> wrote:
Hi !

I'm new to OpenGL, and even after reading tutorials ans manuals, I
still get some troubles.
I'm doing a simple molecular viewer. For simplicity, let's say a
molecules are each a cloud of points, whose centers are not at 0.0 0.0
0.0.
I'd like to rotate it , translate it, and center on any atom, using
the mouse.

1) Rotations: by dragging mouse button-1 , the user rotates around the
x and y axis. X is always horizontal, and Y is always vertical,
whatever the rotation. This works well. Tcl/Tk code of the event
binded routine :

proc HandleRot {x y win} {
         global cx cy

        set mvmatrix [tcl3dVector GLdouble 16]
        glGetDoublev GL_MODELVIEW_MATRIX $mvmatrix
        set mvList   [tcl3dVectorToList $mvmatrix 16]

        glMatrixMode GL_MODELVIEW
        glRotatef $dy [lindex $mvList 0] [lindex $mvList 4] [lindex $mvList
8]

        glGetDoublev GL_MODELVIEW_MATRIX $mvmatrix
        set mvList   [tcl3dVectorToList $mvmatrix 16]
        glRotatef $dx [lindex $mvList 1] [lindex $mvList 5] [lindex $mvList
9]

        set cx $x
        set cy $y

        $win postredisplay
       return

}

2) Translation : I can translate the objects, but when I apply a
rotation, the rotation center is the old rotation center. I 'd like
the rotation center to stay always the center of the scene, and
objects spinning depending on translation.

3) centering: I handle picking and labelling of atoms using NameLists.
I didn't succeed to define the center at the X,Y,Z of the picked
point.

I'm aware there is the gluLookAt function, but How do I retrieve the
eye position ? I don't use gluLookAt at present in my app, so I don't
know if the "eye" position has moved or not, or if it is still at 0.0
0.0 0.0

I would be very gratfull to anybody who could help me !!

Luc

For point 2), ensure the order is translate then rotate and the effect
will be cumulative.
.



Relevant Pages

  • Re: translation and rotation in Euclidean space
    ... In the second place a single rotation only requires a 2x2 matrix. ... do and wish to rotate and translate a scene it is helpful if you process ... a 2d rank tensor, say Lij, a vector is a 1st rank tensor say Xi and ...
    (sci.physics.relativity)
  • Re: translation and rotation in Euclidean space
    ... In the second place a single rotation only requires a 2x2 matrix. ... do and wish to rotate and translate a scene it is helpful if you process ... a 2d rank tensor, say Lij, a vector is a 1st rank tensor say Xi and ...
    (sci.physics.relativity)
  • Re: Object rotation
    ... > need to translate back to the origin first, then rotate, then translate to ... For example rotations are ALWAYS around an axis so if you ... then moves on the new x axis after the Z rotation. ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: Object rotation
    ... need to translate back to the origin first, then rotate, then translate to ... For example rotations are ALWAYS around an axis so if you ... then moves on the new x axis after the Z rotation. ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: Calculating new coordinates in 3D after moving an object
    ... Let's say I want to rotate the line P2-P3 about 14 degrees around the axis P1-P2. ... I assume I first must find the a central point around which the rotation should be done, but since all points are moving... ... The usual method would be to translate the figure so that the ...
    (sci.math)