Coordinate systems

From biophysics
Jump to navigation Jump to search

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.

Cartesian coordinates

Cartesian coordinates in 3 dimensions are described by triples (X,Y,Z) by convention.

In our labs (Sphere, Patient, EEG/NIRS and Robot arm) the speakers are mounted on a semi-circle or a sphere. In the case of the robot arm the movement of the center speaker is describing a sphere. By definition the origin (0,0,0) is the center of the sphere. In an experiment, a subject is sitting in the middle of the sphere and the midpoint between his/her ears should coincide with the center of the origin.

The inspiration for the choice of the XY plane is that the plane is parallel with the natural XY representation of a two dimensional coordinate system projected in front of a person. The axis are chosen with respect to the default position of the subject looking forward to the centre speaker (or in case of the robot arm to the speaker with the arm in the starting position).

  • X-axis: from left (-X) to right (+X)
  • Y-axis: from bottom (-Y) to top (+Y)
  • Z-axis: from back (-Z) to front (+Z)

N.B. The right hand rule does not apply: Z is outer product of (Y,X) instead of (X,Y).

Head tracking coordinates

The convention for head tracking coordinates (H,V,F) is equal to Cartesian coordinates:

  • Horizontal: H = X positive signal when looking right
  • Vertical: V = Y positive signal when looking up
  • Frontal: F = Z positive signal when looking forward

Double Polar coordinates

The double polar coordinates are called Azimuth (Az), Elevation (El) and Radius (Ra). The angle Azimuth defines a semi-circle parallel to the AS plane. The angle Elevation defines a circle parallel to the RA plane. The intersection of the Azimuth semi-circle and the full Elevation circle is the target point.

azimuth

  • Azimuth is the angle with the AS plane.
  • sign(Azimuth) is sign(R)
  • pi/2 <= Azimuth <= pi/2 (or -90° <= Azimuth <= 90°)

elevation

  • Elevation is the angle with the plane for Z >= 0
  • Elevation is pi (180°) minus the angle with the RA plane for A < 0 and S >= 0
  • Elevation is the angle with the RA plane minus pi (180°) for A < 0 and S < 0
  • sign(Elevation) is sign(A)
  • pi <= Elevation <= pi (or -180° <= Elevation <= 180°)

Transformation of double polar to RAS coordinates

R = radius * sin(azimuth)
S = radius * sin(elevation)
|A = -sqrt(radius^2 - R^2 - S^2) for cos(elevation) < 0
|A = +sqrt(radius^2 - R^2 - S^2) for cos(elevation) >= 0

Transformation of Cartesian to double polar coordinates

In the origin we have by definition azimuth = 0 and elevation = 0.

azimuth = arctan2 (R/sqrt (A^2 + S^2))

|elevation =        arctan2 (S/sqrt (R^2 + A^2)), for A>=0
|elevation =   pi - arctan2 (S/sqrt (R^2 + A^2)), for A < 0 and S >= 0
|elevation = - pi - arctan2 (S/sqrt (R^2 + A^2)), for A < 0 and S < 0

radius    = norm([R,A,S])

Matlab functions in Gitlab\biofysica

Functions that are using the above described conventions:

[az, el, r] = RAS2doublePolar(R, A, S)
[R, A, S]   = doublePolar2RAS(az, el, r)
(angles in radials)


Older functions that are using different conventions:

varargout = azel2cart(AZ,EL,R)
azel      = xyz2azel(x,y,z)
(angles in degrees)

Conventions for expressing angles

An angle is normally expressed in radians or degrees.

One radian corresponds to the angle for which the arc (s) on a circle equals the radius (r), thus 1 rad = s/r = 1. In the SI standard 1 rad = 1 per definition, so rad is dimensionless. Therefore it is not necessary to explicitly use it. Only when confusion is possible you should mention it as the unit behind a value.

The other convention for angles is the degree. The conversion between radians and degrees follows from the relation 360° = 2π rad. Note that the degree, with the symbol °, is not a unit of the SI. When expressing angles in degrees the use of the symbol ° is mandatory.

Angles in Matlab

All trigonometry functions in Matlab use radians as unit for angles. Inside your programs it is advised to use only radians in the code and convert to degrees when presenting values for angles on screen, or in an output file. When reading from screen or input file you should convert degrees to radians at the first assignment.

  • It is good practice that angles in conversion functions between Cartesian coordinates and polar, double polar or spherical coordinates are expressed in radians.
  • When expressing angles in degrees is necessary use the following matlab conversion functions:
angle_rad = function deg2rad(angle_deg)
angle_deg = function rad2deg(angle_rad)