COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Local rotation with quaternions

• Email
• Follow

```Hi !

I've some troubles with my camera class.
I use quaternion to performe rotation (interactive rotation on unit
sphere with mouse).
It works.
But when I translate scene, the rotation seems occur around old center
of scene and not the new center (translated).

double dist = Distance();
// Init matrix (unity)
m_Transform.Unit();

// Apply translation of camera
m_Transform.ApplyTranslation(m_CenterSceneRef.U(),
m_CenterSceneRef.V(),
-dist);
// Apply rotation of camera
m_Transform.ApplyRotation(m_CameraOrientation);

// Apply translation from center of model
m_Transform.ApplyTranslation(-m_CenterScene);

// Compute inverse matrix
m_InvTransform = Invert(m_Transform);

// Model Matrix
glMatrixMode(GL_MODELVIEW);

The question is quite simple: how to perform the rotation around the
new center (translated) ?
Of course I tried to change order of operation. But nothing seems to
work.
Any idea ?

Thanks
```
 0

See related articles to this posting

0 Replies
369 Views

Similar Articles

12/10/2013 7:06:45 PM
[PageSpeed]

Similar Artilces:

primitive rotation via mouse
Good day. I am working on primitive rotation via mouse I have read article in NeHe's lessons (#48). Now I have a question. In my project some translations are done after the rotation quaternion is calculated: glPushMatrix(); // Prepare Dynamic Transform glMultMatrixf(Transform.M); ...... //My transorms glTranslate(...) So the rotation in spoiled Do you know how could be the ArcBall class modified to make proper rotation with mouse? Or is there any library that can do the thing for me? Thanks a lot=) Dmitry This should do the trick for you: glMatrixMode(GL_MODELVIEW); glPushMatrix(); //translate glTranslatef(m_v3Translate.m_fX, m_v3Translate.m_fY, m_v3Translate.m_fZ); //move back to centre glTranslatef(m_v3Centre.m_fX, m_v3Centre.m_fY, m_v3Centre.m_fZ); //rotate glRotatef(m_fRotateAngle, m_v3RotateAxis.m_fX, m_v3RotateAxis.m_fY, m_v3RotateAxis.m_fZ); //scale glScalef(m_v3Scale.m_fX, m_v3Scale.m_fY, m_v3Scale.m_fZ); //offset by -ve centre value glTranslatef(-m_v3Centre.m_fX, -m_v3Centre.m_fY, -m_v3Centre.m_fZ); //move down the tree rendeShape(); //get old matrix glMatrixMode(GL_MODELVIEW

Binary rotation with blockage
Hi, I want to rotate a binary number by one each iteration but only if the adjacent location is empty. Examples: 01110000 becomes 00111000 01011011 becomes 00101111 01110011 becomes 00111011 I could use a loop to perform the function but thought there might be a math function to collapse the array in this fashion. Thanks for looking. "Mark" <medwar19.nospam@hotmail.com> wrote in message <gq5g3d\$kch\$1@fred.mathworks.com>... > Hi, > > I want to rotate a binary number by one each iteration but only if the adjacent location is empty. > > Examples

pixel position after rotation
Hi everybody!, I need to rotate an image a certain number of degrees, but I need to know the position of one pixel after rotation, as I know its position before it. Anybody knows how can I make it?. Thank you very much "V�ctor " <vitigcastro_.nospam@gmail.com> wrote in message <fdavlb\$238\$1@fred.mathworks.com>... > Hi everybody!, > > I need to rotate an image a certain number of degrees, but I > need to know the position of one pixel after rotation, as I > know its position before it. > > Anybody knows how can I make it?. Thank you very much How are you rotating the image? help imrotate help maketform input: x,y,p(phi) output: xo,yo rotation matrix: [cos(p) sin(p); -sin(p) cos(p)] [xo yo]=[x y]*[cos(p) sin(p); -sin(p) cos(p)] Roger <roger.merz@gmail.com> wrote in message <1190733784.152152.60970@n39g2000hsh.googlegroups.com>... > help imrotate > help maketform > > input: x,y,p(phi) > output: xo,yo > > rotation matrix: > [cos(p) sin(p); -sin(p) cos(p)] > > [xo yo]=[x y]*[cos(p) sin(p); -sin(p) cos(p)] > > Maybe I am being a bit thick - its getting late, and I have had

Rotation of 3D objects
By what command is it possible to create (without writing a code separately ): 1) Reflections of 3D objects about a plane? 2) Multiple copies equally spaced by rotation around an axis through two given points? E.g., surf = ParametricPlot3D[{ t,u+t, u*t/5}, {t,0,2},{u,-1,1}]; Rotate[surf,Axis->{ {-1,-1,-1},{1,1,1}} , Copies-> 4 ] ; and, 3) A single rotation of given object through a given angle on an axis through two defined points? Thanks in advance Narasimham Hi, we all dream of a computer that read our mind and does what we want "without writing a code separately ". Wait 200 years or better 500 years Regards Jens Narasimham wrote: > By what command is it possible to create (without writing a code > separately ): > > 1) Reflections of 3D objects about a plane? > > 2) Multiple copies equally spaced by rotation around an axis through > two given points? > > E.g., > surf = ParametricPlot3D[{ t,u+t, u*t/5}, {t,0,2},{u,-1,1}]; > Rotate[surf,Axis->{ {-1,-1,-1},{1,1,1}} , Copies-> 4 ] ; and, > > 3) A single rotation of given object through a given angle