Difference between revisions of "Coordinate systems"

From biophysics
Jump to navigation Jump to search
Line 1: Line 1:
 
==Introduction==
 
==Introduction==
In Cartesian three dimensions you can have different coordinate systems. In our audio lab we define  
+
In the three dimensions of our world you can define different coordinate systems. In our auditory labs a subject is placed with his head in the center of the speaker setup (a sphere or semi-circle). We define all coordinate systems with respect to the default position of the head of the subject. Normally we are interested in the direction of a stimulus and we therefore define the directions with the angles azimuth and elevation in a double polar coordinate system. This system is a non-conventional coordinate system that is not used often beyond auditory experiments. The standard system is the Spherical Coordinate System. Both the Azimuth and Elevation are calculated differently in these two systems.
 +
 
 +
The head tracking system uses three orthogonal axis: Horizontal, Frontal, Vertical. Sometimes we refer to them as X, Y and Z. In the following paragraphs each of the double polar and Cartesian coordinate systems are defined as they are used in our auditory labs.
  
 
+
When your are interested in the Spherical coordinate system you have to ask Wikipedia or other sources.
==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 (+)
 
 
 
N.B. The Z-hat vector is the outer product of the X-hat vector and Y-hat vector (right hand rule).
 
 
 
The convention for head tracking coordinates is equal to Cartesian coordinates
 
*Horizontal = X
 
*Frontal = Y
 
*Vertical = Z
 
 
 
==Convention for spherical coordinates==
 
In the spherical coordinate system the position of a given point in space is specified by three numbers, (r, θ, φ): the radial distance of the radial line r connecting the point to the fixed point of origin (which is located on a fixed polar axis, or zenith direction axis, or z-axis); the polar angle θ of the radial line r; and the azimuthal angle φ of the radial line r.
 
*The elevation or polar angle θ is the angle with Z-hat.
 
*The elevation runs from 0 to pi.
 
*The azimuth or azimuthal angle φ is the angle of the projection to the XY plane with X-hat in the anti clockwise direction.
 
*The azimuth runs from 0 to 2pi.
 
 
 
This is the so-called physics convention (ISO 80000-2:2019).
 
  
 
==Convention for double polar coordinates==
 
==Convention for double polar coordinates==
Line 45: Line 25:
 
*5 Take the angle of this vector with the Y-hat. This is the elevation.
 
*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
 
*6 Angles larger than pi/2 are folded back by mirroring
 +
 +
==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 (+)
 +
 +
N.B. The Z-hat vector is the outer product of the X-hat vector and Y-hat vector (right hand rule).
 +
 +
The convention for head tracking coordinates is equal to Cartesian coordinates:
 +
*Horizontal = X
 +
*Frontal = Y
 +
*Vertical = Z
  
 
===How to get the angle between two vectors===  
 
===How to get the angle between two vectors===  

Revision as of 15:31, 14 February 2024

Introduction

In the three dimensions of our world you can define different coordinate systems. In our auditory labs a subject is placed with his head in the center of the speaker setup (a sphere or semi-circle). We define all coordinate systems with respect to the default position of the head of the subject. Normally we are interested in the direction of a stimulus and we therefore define the directions with the angles azimuth and elevation in a double polar coordinate system. This system is a non-conventional coordinate system that is not used often beyond auditory experiments. The standard system is the Spherical Coordinate System. Both the Azimuth and Elevation are calculated differently in these two systems.

The head tracking system uses three orthogonal axis: Horizontal, Frontal, Vertical. Sometimes we refer to them as X, Y and Z. In the following paragraphs each of the double polar and Cartesian coordinate systems are defined as they are used in our auditory labs.

When your are interested in the Spherical coordinate system you have to ask Wikipedia or other sources.

Convention for double polar coordinates

  • Azimuth is the angle of the projection to the XY plane with Y-hat.
  • Elevation is angle of the projection to the YZ plane with Y-hat.
  • Azimuth is between -pi and pi and positive in the X-hat direction.
  • Elevation is between -pi/2 and pi/2 and positive in the Z-hat direction.
  • In the negative Y direction the Elevation is mirrored (Elevation = angle with minus Y-hat).

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

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 (+)

N.B. The Z-hat vector is the outer product of the X-hat vector and Y-hat vector (right hand rule).

The convention for head tracking coordinates is equal to Cartesian coordinates:

  • Horizontal = X
  • Frontal = Y
  • Vertical = Z

How to get the angle between two vectors

The algorithm makes use of: dotproduct(V1,V2) = |V1|*|V2|*cos(angle) to determine the angle.

function theta = getAngle(V1, V2)
    dotProduct = dot(V1, V2);   
    norm1 = norm(V1);
    norm2 = norm(V2);    
    if norm1 * norm2 > 0
        cosTheta = dotProduct / (norm1 * norm2);
        theta = acos(cosTheta);        
    else
        theta = 0;
    end    
end

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]);
    
    % take the quadrants into account
    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 and Y=0)
            azimuth = 0;
    end

    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 and Z=0)
            elevation = 0;
    end