# Math noob - rotation formulas

## Recommended Posts

Hi

Trying to implement several of these rotation formulas with simple geometry

for instance the first example

Quote

• add rotation X (x, y*cos(rx) + z*sin(rx), y*-sin(rx) + z*cos(rx))

(x, y*cos(rx) + z*sin(Rx), y*-sin(rx) + z*cos(rx))

```x = x

y = y*cos(rx) + z*sin(Rx)

z = y*-sin(rx) + z*cos(rx)```

How would you implement this as Vex within a Point Wrangle?

Edited by art3mis

##### Share on other sites

Hi,

While rotating an object, we are essentially changing the position of the points of the Geo.

So, the above mentioned formula changes the point position along y and z axis but not x axis. To implement it in a point wrangle, just drop in a test object on to the grid followed by a point wrangle and enter the following code in the wrangle :

```float angleX = ch("xRad");
float posY = @P.y*cos(angleX) + @P.z*sin(angleX);
float posZ = @P.y*(-sin(angleX)) + @P.z*cos(angleX);
@P = set(@P.x, posY, posZ);```

Change the "xRad" parameter, the object "appears" to be rotating along the X-Axis, but in reality, it is just changing the point positions along Y and Z axis.

Hope it helps!

S

## Create an account

Register a new account