I've got this far to understanding 2d rotation, the new x is the radius *

the cos of an an angle in radians

plus the radius(same as radius, for a circle) offset by 100 (offset from the

0,0 origin (top left of screen/form). y is similar, but I'm stuck on

rotation about an arbitrary point

The books say move the arbitrary point to the origin, rotate then translate

the arbitrary point back to the previous location. I'm trying to do this

without matrix calculations.

'clockwise rotation

x = radius * Cos(angleinradians) + radius * Sin(angleinradians) + 100

y = radius * Sin(angleinradians) - radius * Cos(angleinradians) + 100

Any help? Thank you.

First do the translation:

x = x + xOffset

y = y + yOffset

then do the rotations, and then finally translate back

x = x - xOffset etc

Jim Deutch

MS Dev MVP

>I've got this far to understanding 2d rotation, the new x is the radius *

>the cos of an an angle in radians

>plus the radius(same as radius, for a circle) offset by 100 (offset from

the

>0,0 origin (top left of screen/form). y is similar, but I'm stuck on

>rotation about an arbitrary point

>The books say move the arbitrary point to the origin, rotate then

translate

>the arbitrary point back to the previous location. I'm trying to do this

>without matrix calculations.

>'clockwise rotation

> x = radius * Cos(angleinradians) + radius * Sin(angleinradians) + 100

> y = radius * Sin(angleinradians) - radius * Cos(angleinradians) + 100

>Any help? Thank you.

1. Rotating an object around an arbitrary fixed point

I know that glRotatef rotates around the origin (0,0,0). Now I want to

rotate an object around its own center. Let's say that the object's

center is located at (5,5,0). I should be able to rotate the object

around around the z-axis by first translating the object's center to the

origin, then rotate the object, and then translate the object back to

its original position.

code:

glPushMatrix();

glColor3f(1,0,0);

glTranslatef(-5,-5,0); // Put the fixed point at the origin

glRotatef(45,0,0,1); // Rotate 45 degrees around the z-axis

glTranslatef(5,5,0); // Translate back to original position

glBegin(GL_LINES);

glVertex3f(0,0,0);

glVertex3f(10,0,0);

glVertex3f(0,0,0);

glVertex3f(0,10,0);

glVertex3f(10,0,0);

glVertex3f(0,10,0);

glEnd();

glPopMatrix();

The problem however, is that due to the first translation, the origin

gets translated too! So the object doesn't get rotated around its own

center but still around the origin! How the heck can I get this working?

Any help is appreciated.

Regards,

Boris

3. Rotating a point around an arbitrary line in 3D

4. Inserting points/lines in a BSP tree

5. Rotate around arbitrary point?

6. DOC2TEX

7. Newbie: Problem using Affect Pivot point for Rotating around objects XYZ

8. Tcl/Tk Widget for Inventor??

9. Rotating objects around the same point

10. Moving around, rotating around objects

11. Rotating Around An Arbitrary Axis

12. Rotating vectors around arbitrary axes

13. Rotating around arbitrary axis

2 post • Page:**1** of **1**