Difference between revisions of "Coordinate systems"

From biophysics
Jump to navigation Jump to search
Line 48: Line 48:
  
 
|elevation =        arctan2 (Y/sqrt (X^2 + Z^2)), for Z>=0
 
|elevation =        arctan2 (Y/sqrt (X^2 + Z^2)), for Z>=0
|elevation =   pi - arctan2 (Y/sqrt (X^2 + Z^2)), for Z < 0 and Y >= 0
+
|elevation =   pi - arctan2 (Y/sqrt (X^2 + Z^2)), for Z < 0 and Y >= 0
|elevation = - pi - arctan2 (Y/sqrt (X^2 + Z^2)), for Z < 0 and Y < 0
+
|elevation = - pi - arctan2 (Y/sqrt (X^2 + Z^2)), for Z < 0 and Y < 0
  
 
radius    = norm([X,Y,Z])
 
radius    = norm([X,Y,Z])

Revision as of 11:31, 26 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.

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 (R). The angle Azimuth defines a semi-circle parallel to the YZ plane. The angle Elevation defines a circle parallel to the XY plane. The intersection of the Azimuth semi-circle and the full Elevation circle is the target point.

azimuth

  • Azimuth is the angle (theta) with the YZ plane for +Y and pi - theta for -Y.
  • sign(Azimuth) is sign(X)

elevation

  • Elevation is the angle with the XY plane.
  • sign(Elevation) is sign(Z)

Transformation of double polar to Cartesian coordinates

X = radius * sin(azimuth)
Z = radius * sin(elevation)
|Y = -sqrt(radius^2 - X^2 - Z^2) for cos(azimuth)*cos(elevation) < 0
|Y = +sqrt(radius^2 - X^2 - Z^2) for cos(azimuth)*cos(elevation) >= 0

Transformation of Cartesian to double polar coordinates

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

azimuth = arctan2 (X/sqrt (Y^2 + Z^2))

|elevation =        arctan2 (Y/sqrt (X^2 + Z^2)), for Z>=0
|elevation =   pi - arctan2 (Y/sqrt (X^2 + Z^2)), for Z < 0 and Y >= 0
|elevation = - pi - arctan2 (Y/sqrt (X^2 + Z^2)), for Z < 0 and Y < 0

radius    = norm([X,Y,Z])

Matlab functions in Gitlab\biofysica

Functions that are using the above described conventions:

[az, el, r] = cart2doublePolar(X, Y, Z)
[X, Y, Z]   = doublePolar2cart(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)