## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# Low-Level Quaternion Rotation

If you want to write code yourself that performs rotations, you can use the Quaternion structure with the rotation formulas I've shown you. For example, suppose you want to rotate the variable point of type Point3D by angle degrees around the axis vector. You first need to get a rotation quaternion and its conjugate:

```Quaternion qRotate = new Quaternion(axis, angle);
Quaternion qConjugate = qRotate;
qConjugate.Conjugate();```

Now convert the Point3D object to a pure quaternion:

`Quaternion qPoint = new Quaternion(point.X, point.Y, point.Z, 0);`

Multiply that point by the rotation quaternion on the left and its conjugate on the right:

`Quaternion qRotatedPoint = qRotate * qPoint * qConjugate;`

And convert back to a Point3D:

`pointRotated ...`

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required