# Houdini - Multiplying Quaternions

From this exercise and the following lines:

```
vector4 o = dihedral({0, 0, 1}, @P); // align z-axis with @P vector
```

We get this result:

Now we want to face her ass out, which means we gotta rotate her 90-degrees on her y-axis.

From this exercise, we learned how to build a quarternion from a rotation and an axis.

```
vector4 r = quaternion(set(0, radians(90), 0)); // e.g {0, 90, 0} - rotate y 90-deg
```

We combine both the rotations by multiplying the quarternions, using qmultiply:

```
// Full example:
vector4 o = dihedral({0,0,1}, @P); // Stand up, face out
vector4 r = quaternion(set(0, radians(90), 0)); // Ass out
@orient = qmultiply(o, r);
```

Which gets us:

Remember that multiplying quarternions is *non-communicative* so `A(B) ≠ B(A)`

and leads to different orientations. In this case it doesn’t matter, but when you start mixing axes, trouble starts.

Since she’s got her ass out, let’s rotate the “platform”:

### Orbit

We want to rotate her around a center, while she is tilted 45-degress. So, something like this:

The first thing is just to get some rotation happening, since that is easiest to figure out:

```
@orient = quaternion(set(0, @Time, 0)); // Rotate on Y over @Time
```

Which gets us:

Now we just gotta rotate her 45-deg, which means we need a transformation matrix that rotates the top of her head `{0, 1, 0}`

which points straight up – to `{-1, 1, 0}`

– which is up and in `-x`

.

So, the complete solution:

```
@orient = quaternion(set(0, @Time, 0)); // spin with time
vector4 m = dihedral({0, 1, 0}, {-1, 1, 0}); // rotate 45-deg
@orient = qmultiply(@orient, m); // combine
```