# HOA Technical Notes - B-Format Rotation

Once you have a B-Format audio stream, it's possible to manipulate it in various ways. For instance, you can rotate it using matrix multiplication. This moves all material in the soundfield.

## Conventions

This page includes second order rotation matrices for SN3D-encoded B-Format for each of the three axes (X, Y and Z) given a rotation angle. It's possible to form other rotations by combining these. These are left-hand-side matrices (and so should be applied as `out[t]=matrix*in[t]`

).

These rotations are sometimes known as "rotate" (Z), "tilt" (X) and "tumble" (Y) in the Ambisonic literature, or "yaw" (Z), "pitch" (Y) and "roll" (X).

For first order rotation, just use the top left corner four-by-four matrix. For rotations up to third order, you can use the O3A Rotation plugin from the O3A Core plugin library.

## X Axis Rotation ("Roll")

This rotates around the X (front/back) axis. This is sometimes known as "tilt" in the Ambisonic literature.

ACN | 0 In | 1 In | 2 In | 3 In | 4 In | 5 In | 6 In | 7 In | 8 In |
---|---|---|---|---|---|---|---|---|---|

0 Out | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |

1 Out | 0 | cos(a) | -sin(a) | 0 | 0 | 0 | 0 | 0 | 0 |

2 Out | 0 | sin(a) | cos(a) | 0 | 0 | 0 | 0 | 0 | 0 |

3 Out | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |

4 Out | 0 | 0 | 0 | 0 | cos(a) | 0 | 0 | -sin(a) | 0 |

5 Out | 0 | 0 | 0 | 0 | 0 | cos(2a) | -sqrt(3/4) sin(2a) | 0 | -1/2 sin(2a) |

6 Out | 0 | 0 | 0 | 0 | 0 | sqrt(3/4) sin(2a) | 1/4 (1+3cos(2a)) | 0 | -sqrt(3/16) (1-cos(2a)) |

7 Out | 0 | 0 | 0 | 0 | sin(a) | 0 | 0 | cos(a) | 0 |

8 Out | 0 | 0 | 0 | 0 | 0 | 1/2 sin(2a) | -sqrt(3/16) (1-cos(2a)) | 0 | 1/4 (3+cos(2a)) |

## Y Axis Rotation ("Pitch")

This rotates around the Y (left/right) axis. This is sometimes known as "tumble" in the Ambisonic literature.

ACN | 0 In | 1 In | 2 In | 3 In | 4 In | 5 In | 6 In | 7 In | 8 In |
---|---|---|---|---|---|---|---|---|---|

0 Out | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |

1 Out | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |

2 Out | 0 | 0 | cos(a) | sin(a) | 0 | 0 | 0 | 0 | 0 |

3 Out | 0 | 0 | -sin(a) | cos(a) | 0 | 0 | 0 | 0 | 0 |

4 Out | 0 | 0 | 0 | 0 | cos(a) | -sin(a) | 0 | 0 | 0 |

5 Out | 0 | 0 | 0 | 0 | sin(a) | cos(a) | 0 | 0 | 0 |

6 Out | 0 | 0 | 0 | 0 | 0 | 0 | 1/4 (1+3cos(2a)) | sqrt(3/4) sin(2a) | sqrt(3/16) (1-cos(2a)) |

7 Out | 0 | 0 | 0 | 0 | 0 | 0 | -sqrt(3/4) sin(2a) | cos(2a) | 1/2 sin(2a) |

8 Out | 0 | 0 | 0 | 0 | 0 | 0 | sqrt(3/16) (1-cos(2a)) | -1/2 sin(2a) | 1/4 (3+cos(2a)) |

## Z Axis Rotation ("Yaw")

This rotates around the Z (up/down) axis, i.e. horizontally. This is sometimes known as "rotate" in the Ambisonic literature.

ACN | 0 In | 1 In | 2 In | 3 In | 4 In | 5 In | 6 In | 7 In | 8 In |
---|---|---|---|---|---|---|---|---|---|

0 Out | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |

1 Out | 0 | cos(a) | 0 | sin(a) | 0 | 0 | 0 | 0 | 0 |

2 Out | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |

3 Out | 0 | -sin(a) | 0 | cos(a) | 0 | 0 | 0 | 0 | 0 |

4 Out | 0 | 0 | 0 | 0 | cos(2a) | 0 | 0 | 0 | sin(2a) |

5 Out | 0 | 0 | 0 | 0 | 0 | cos(a) | 0 | sin(a) | 0 |

6 Out | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |

7 Out | 0 | 0 | 0 | 0 | 0 | -sin(a) | 0 | cos(a) | 0 |

8 Out | 0 | 0 | 0 | 0 | -sin(2a) | 0 | 0 | 0 | cos(2a) |