### Author Topic: how to let rotationmartrix only rotate without translation?  (Read 2323 times)

#### Uncle Ray

• int
• Posts: 81
##### how to let rotationmartrix only rotate without translation?
« on: September 03, 2014, 05:21:49 am »
I know in fact the setrotationmartix include translation,but i dont need the translation,just need rotate only,
how to solved?Any help will be appreciated.

#### Uncle Ray

• int
• Posts: 81
##### Re: how to let rotationmartrix only rotate without translation?
« Reply #1 on: September 03, 2014, 07:06:20 am »
|          |
|          |      step:1
|          |
|          |
|        / |
|      /   |
|     /    |→→→→waypoint
|    /     |
|          |
|   ▲    |→→→→→car

|          |
|          |      step:2
|          |
|          |
|        / |
|      /   |→→→→→→waypoint
|    ▲   |→→→→car(car must rotation,and it's face should be the same as waypoint's)
|    /     |
|          |
|          |

#### EgonOlsen

• Posts: 12202
##### Re: how to let rotationmartrix only rotate without translation?
« Reply #2 on: September 03, 2014, 09:23:38 am »
The rotation matrix can include a translation, but it's not supposed to. It just can, because it's a 4x4 matrix. Just remove the translational part from the it before setting it.

#### Uncle Ray

• int
• Posts: 81
##### Re: how to let rotationmartrix only rotate without translation?
« Reply #3 on: September 03, 2014, 11:07:31 am »
how to removed?example matrix a=A.getrotatematrix.
┎                           ┓
│ a00 a01 a02 a03│
│ a10 a11 a12 a13│
a= │ a20 a21 a22 a23│
│ a30 a31 a32 a33│
┖                            ┛
a.setrow(3,0,0,0,1)

means:
(a30=0,a31=0,a32=0,a33=1)

i know this is wrong,but how to correct.what is the right code?

#### EgonOlsen

• Posts: 12202
##### Re: how to let rotationmartrix only rotate without translation?
« Reply #4 on: September 03, 2014, 12:08:52 pm »
No, that's actually correct.

#### Uncle Ray

• int
• Posts: 81
##### Re: how to let rotationmartrix only rotate without translation?
« Reply #5 on: September 03, 2014, 06:48:09 pm »
but the fact is thranslation still alive;here is my code

{SimpleVector front=obj_car.getZAxis();
front.scalarMul(-1);
Matrix a03=obj_wp[i_check1].getRotationMatrix();
a03.setRow(3, 0, 0, 0, 1);
if(obj_car.checkForCollision(front, 2.5f)==obj_wp[1].getID())
{obj_car.setRotationMatrix(a03);}

}

the fact is obj_car still translation.......

#### EgonOlsen

• Posts: 12202
##### Re: how to let rotationmartrix only rotate without translation?
« Reply #6 on: September 03, 2014, 07:31:30 pm »
Must be something else then...if that getRotationMatrix() call is the one from Object3D, it doesn't contain any translations anyway. You can check this by simply printing out the matrix. Keep in mind that the outcome of a rotation will also be influenced by the objects rotation pivot as well as any translation or rotation of a parent object.

#### Uncle Ray

• int
• Posts: 81
##### Re: how to let rotationmartrix only rotate without translation?
« Reply #7 on: September 03, 2014, 08:12:49 pm »
may be the point is the model?
i tried another model,which is the same model like obj_car.
here is really just rotation no more translation,but have a question?

{SimpleVector front=obj_car.getZAxis();
front.scalarMul(-1);
Matrix a03=obj_wp[1].getRotationMatrix();
a03.setRow(3, 0, 0, 0, 1);
if(obj_car.checkForCollision(front, 2.5f)==obj_wp[1].getID())
{obj_car.setRotationMatrix(a03);}

}

question:
1,when i rotate obj_car,obj_wp[1] was rotated too,why?
2.i just want the obj_car and obj_wp[]1 have the same face in the world space,no translation,just rotateisY or rotateYaxis .
Is there a better suggest?

PS:recently,i have asked so many questions, and you always  have the best answer,thanks again,

#### EgonOlsen

`obj_car.getRotationMatrix().setTo(a03); `