Difference between revisions of "Coordinate systems"
Jump to navigation
Jump to search
(→=) |
|||
Line 35: | Line 35: | ||
*6 Angles larger than pi/2 are folded back by mirroring | *6 Angles larger than pi/2 are folded back by mirroring | ||
− | === | + | ===How to get the angle between two vectors=== |
− | The algorith uses the inverse of: dotproduct(V1,V2) = | + | The algorith uses the inverse of: |
− | |V1|*|V2|*cos(angle) to determine the angle. | + | dotproduct(V1,V2) = |V1|*|V2|*cos(angle) to determine the angle. |
+ | So: ''angle = acos(dotproduct(V1,V2)/(|V1|*|V2|))'' | ||
+ | ===cart2double_polar(X, Y, Z)=== | ||
<pre> | <pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
function [azimuth, elevation, r] = cart2double_polar(X, Y, Z) | function [azimuth, elevation, r] = cart2double_polar(X, Y, Z) | ||
Line 84: | Line 78: | ||
elevation = 0; | elevation = 0; | ||
end | end | ||
− | |||
</pre> | </pre> |
Revision as of 14:47, 14 February 2024
Convention for Cartesian coordinates
- Middle of the sphere is (0, 0, 0)
- X is left (-) to right (+)
- Y is back (-) to front (+)
- Z is bottom (-) to top (+)
The convention for head tracking coordinates is equal to Cartesian coordinates
- Horizontal = X
- Frontal = Y
- Vertical = Z
Convention for spherical coordinates
Convention for double polar coordinates
% azimuth is angle (in rad) with YZ plane with Y-hat is zero and X-hat is % pi/2. % elevation is angle (in rad) with XY plane with Y-hat is zero Z-hat is % pi/2.
Conversion from Cartesian to Double Polar
% Double polar coördinates is a non-standard coördinate system used for audiological purposes only.
The procedure for transformation is the following:
- 1 Project the Cartesian coordinates to the XY-plane.
- 2 This forms a two dimensional vector in the XY-plane.
- 3 Take the angle of this vector with the Y-hat. This is the azimuth.
- 4 Project the Cartesian coordinates to the YZ-plane.
- 5 Take the angle of this vector with the Y-hat. This is the elevation.
- 6 Angles larger than pi/2 are folded back by mirroring
How to get the angle between two vectors
The algorith uses the inverse of: dotproduct(V1,V2) = |V1|*|V2|*cos(angle) to determine the angle.
So: angle = acos(dotproduct(V1,V2)/(|V1|*|V2|))
cart2double_polar(X, Y, Z)
function [azimuth, elevation, r] = cart2double_polar(X, Y, Z) r = sqrt(X^2+Y^2+Z^2); %azimuth: projection to XY plane, angle with Y_hat az_angleWithY_hat = getAngle([X,Y,0],[0,1,0]); %elevation: projection to YZ plane, angle with Y_hat el_angleWithY_hat = getAngle([0,Y,Z],[0,1,0]); % azimuth from -pi to +pi switch findQuadrant(X, Y) % Quadrants are numbered anti-clockwise case {1,4} azimuth = az_angleWithY_hat; case {2, 3} azimuth = - az_angleWithY_hat; case 0 % (X=0 or Y=0) azimuth = 0; end % elevation from -pi/2 to +pi/2 switch findQuadrant(Y, Z) case 1 elevation = el_angleWithY_hat; case 2 elevation = pi - el_angleWithY_hat; case 3 elevation = el_angleWithY_hat - pi; case 4 elevation = - el_angleWithY_hat; case 0 % (Y=0 or Z=0) elevation = 0; end