• Create Account

### #ActualGDsnakes

Posted 06 December 2012 - 08:03 PM

When you say:

x' = x*cos(A) - y*sin(A)
y' = y*cos(A) + x*sin(A)

Does your code happen to 'actually' do:

x = x*cos(A) - y*sin(A)
y = y*cos(A) + x*sin(a)

aka, you update the value for x, then you are using the new value for x in the computation for y isntead of the old one?

No. I apply it to the original slope of Object B.

Like this:

glPushMatrix();
glTranslatef(BaseAX+(60.0*cos(AngleD)-10.0*sin(AngleD)),baseAY+(10.0*cos(AngleD)-60.0*sin(AngleD)),0.0f);
//Set color
glColor4f(blah);

Draw stuff

glEnd();
glPopMatrix();

Where 60 is the original "run" and 10 the original "rise". I changed the + to a - for the Y because my Y axis is inverted. Origin is (0,1500). I noticed that when it was a + the object rotated the opposite way as the mouse. When changed to a - it followed the mouse like its supposed to.

Image a gun with 3 parts rotating around the player. The gun base and two other parts of the gun A and B. A/B are at a slope to the base. They are always X over and Y up as an ex. Now if the gun rotates around the player you have to account for the rotation in the slope. Which led to the equations.

x = x*cos(A) - y*sin(A)
y = y*cos(A) + x*sin(a)

problem is that the slope isn't preserved like I want. These objects move on top of each other (Their x becomes 0) as I rotate ( at 90 degree intervals. So between o degrees and 90, 90-180, 180-270, 270-360) they flip in these intervals. In each one the parts all move to the center being on top of each other(having the same slope even though I use their own respective "rises"/"runs" when I translate using the equation) then they continue until they're flipped opposite if when they entered the 90 degree interval. Same as they go through each one. So at each axis the slope is right (but upside down at 180) but in between the go through this process of shifting to the opposite side, being on top of each other at 45 deg.

### #1GDsnakes

Posted 06 December 2012 - 07:51 PM

When you say:

x' = x*cos(A) - y*sin(A)
y' = y*cos(A) + x*sin(A)

Does your code happen to 'actually' do:

x = x*cos(A) - y*sin(A)
y = y*cos(A) + x*sin(a)

aka, you update the value for x, then you are using the new value for x in the computation for y isntead of the old one?

No. I apply it to the original slope of Object B.

Like this:

glPushMatrix();
glTranslatef(BaseAX+(60.0*cos(AngleD)-10.0*sin(AngleD)),baseAY+(10.0*cos(AngleD)-60.0*sin(AngleD)),0.0f);
//Set color
glColor4f(blah);

Draw stuff

glEnd();
glPopMatrix();

Where 60 is the original "run" and 10 the original "rise". I changed the + to a - for the Y because my Y axis is inverted. Origin is (0,1500). I noticed that when it was a + the object rotated the opposite way as the mouse. When changed to a - it followed the mouse like its supposed to.

Image a gun with 3 parts rotating around the player. The gun base and two other parts of the gun A and B. A/B are at a slope to the base. They are always X over and Y up as an ex. Now if the gun rotates around the player you have to account for the rotation in the slope. Which led to the equations.

x = x*cos(A) - y*sin(A)
y = y*cos(A) + x*sin(a)

problem is that the slope isnt preserved like I want. These objects move on top of eachother (Their x becomes 0) as I rotate ( nearing the Y axis at 90/270 degrees) then they continue in that direction as I approach 180 degress where by the time the angle is actually 180 its flipped(mirrored and upside down when it should just be mirrored). .

PARTNERS