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

chained object rotation on a fix point

• Email
• Follow

```I'm having trouble with rotation on a fixed point. There are a line of
sphere that I have already created. and let say I have a point name
with jointX,jointY which are the location that I want my lines of
sphere to rotate from(not from the origin). but I got stuck at a point
where the line of sphere disappear. some code might explain my problem

[code]

float tempX = 0;
float tempY = 0;
float updateX;
float updateY;

_jointX = upperLegJointX;     //the point of rotation
_jointY = upperLegJointY;

for(int i = 0; i < 10; i++){

objects sphere = lowerLegArray[i];		//get each sphere in the array

tempX = sphere.getLocationX();		//get the current X location of the
sphere within the array
tempY = sphere.getLocationY();		//get the current Y location of the
spehre within the array

//calclate the new X Y location of the sphere
updateX = cos((float)0.05f) * _jointX - sin((float)0.05f) * _jointY;
updateY = sin((float)0.05f) * _jointX + cos((float)0.05f) * _jointY;

//translate back into the origin using the original X/Y(tempX/Y)
//then tranlte it into the new calculated value
glPushMatrix();
glTranslatef(updateX, updateY , 0);
glTranslatef(tempX, tempY, 0);
sphere.sphere();
glPopMatrix();

lowerLegArray[i].setLocation(updateX, updateY);			//save it back into
the array

}
[/code]

it seems that every single sphere keep translate back to the joint's
location. Any suggestion that might solve this problem? Is all I
missing is the displacement between the joint and the new location of
the sphere?

```
 0
Reply saipkjai (3) 10/16/2006 4:26:29 AM

See related articles to this posting

0 Replies
223 Views

Similar Articles

12/9/2013 1:37:48 AM
[PageSpeed]