# Rotating quad around itself but move it to a specific position of another quad

• 07-02-2013, 02:07 PM
CDGJosh
Rotating quad around itself but move it to a specific position of another quad
Hey,
i have the following problem: i have following setup:

The red quad should always keep the position relative to the white quad. I got this working by using the same translation and rotation matrix as the white quad.
The red one "recieves" the matrices from the white one.

img at: cdg.bplaced.net/2.PNG (would have used IMG tag, but was denied :( )

Now i want to rotate the red quad around itself. I do it, by adding the amout of degree to the one recieved from the parent object and using it as the values for the rotation matrix:

Code :

```ikarusRotationMatrix: cos(deg+turnDeg), -sin(deg+turnDeg), 0.0, 0.0 sin(deg+turnDeg), cos(deg+turnDeg), 0.0, 0.0 0.0, 0.0, 1.0, 0.0 0.0, 0.0, 0.0, 1.0```

deg: the amout the white quad is rotated
turnDeg: the amount the red quad should be rotated

The problem now is, that if i let it rotate, it starts rotating around the center of the white quad.

I now have the question, how i can rotate it around itself but let it stay at the position relative to the white quad?

```#version 150 core   in vec4 in_Position; in vec4 in_Color; in vec2 in_TextureCoord;   uniform mat4 window_Matrix; uniform mat4 ikarus_Rotation_Matrix; uniform mat4 translation_Matrix; uniform mat4 ntranslation_Matrix;   out vec4 pass_Color; out vec2 pass_TextureCoord;     void main(void) {   gl_Position = window_Matrix * translation_Matrix * ikarus_Rotation_Matrix * in_Position;   pass_TextureCoord = in_TextureCoord; pass_Color = in_Color;     }```