-
Notifications
You must be signed in to change notification settings - Fork 28
/
rotateHOA_N3D.m
46 lines (41 loc) · 1.59 KB
/
rotateHOA_N3D.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function hoasig_rot = rotateHOA_N3D(hoasig, yaw, pitch, roll)
%ROTATEHOA_N3D Rotate a HOA encoded sound scene, by yaw-pitch-roll angles.
% ROTATEHOA_N3D takes an input HOA signal set and according to a
% specified rotation of the coordinate system, returns the HOA signals
% on the rotated frame.
%
% The convention used is of a right-hand coordinate, active rotation,
% yaw-pitch-roll convention, with yaw applied first, then pitch, then roll.
%
% The code requires the Spherical Harmonic transform library (for the
% euler2rotationMatrix() and getSHrotMtx() function) found in:
%
% <https://github.com/polarch/Spherical-Harmonic-Transform>
%
% For more information on the rotations in the SH domain, and the specific
% implementation, check the documentation of the above library.
%
% Inputs:
% hoasig: HOA signals, N3D, ACN normalization and channel ordering
% yaw: yaw angle in degrees, around z (first rotation)
% pitch: pitch angle in degrees, around y' (second rotation)
% roll: roll angle in degrees, around x'' (third rotation)
% Outputs:
% bfsig_rot: rotated HOA signals
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Archontis Politis, 15/11/2015
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% get order
Nchan = size(hoasig,2);
Nord = sqrt(Nchan)-1;
% get rotation matrix
Rzyx = euler2rotationMatrix(-yaw*pi/180, -pitch*pi/180, roll*pi/180, 'zyx');
% compute rotation matrix in the SH domain
Rshd = getSHrotMtx(Rzyx, Nord, 'real');
% apply to hoa signals
hoasig_rot = hoasig * Rshd.';
end