# rotation matrix to degrees

## Recommended Posts

In Python is this function setWorldTransform wich translates a matirx to "transforms". How to do this in vex? Scale and transformation is easy, but is there a function for rotation?

##### Share on other sites

I don't know if it's what you are looking for exactly, but the instance function create a transformation matrix. You just need to multiply to @P.

Here a simple vex code to rotate all points with an axis and pivot attributes previously defined.

```// rotate
vector scale, postrotation;
vector4 orient;

float angle = ch("ang");
matrix3 rotm = ident();
orient = quaternion(rotm);
scale = 1;
postrotation = 0;
matrix xform;
xform = instance(v@pivot, @N, scale, postrotation , orient, v@pivot);

@P *= xform;```

EDIT: You can also take a look with quaternion, eulertoquaternion, qrotate, etc.. for rotation

Edited by fsimerey
• 1

##### Share on other sites

Hi Johannes,

have you looked into cracktransform() yet? It extracts transform vectors one at a time:

```// translate (c=0), rotate (c=1), scale (c=2), or shears (c=3)
vector  cracktransform(int trs, int xyz, int c, vector pivot, vector pivot_rotate, matrix xform)```
• 2

##### Share on other sites

Hi,

thanks for your replies, but I think I didn't explained well enough what I mean. The setWorldTransform in Python uses a Matrix to set transforms on an object with rotations in degrees.

Basically I want to have euler angles from a given matrix.

Edited by Drughi

##### Share on other sites

Konstantin gave you the answer already. Use cracktransform in VEX... this will return euler rotations.

• 1

##### Share on other sites

You'r right, I misunderstood. Got it now. Thanks.

## Create an account

Register a new account