# How is a coordinate transformation done?

FollowThe starting point is a binary-to-ASCII conversion of the raw data file so that you have access to the three velocity files, .v1, .v2 and .v3, the transformation matrix in the .hdr file, and the .sen file. Heading, pitch and roll are presented in the .sen file (ref. the .hdr file), and these angles are output in degrees. The figure below indicates the three coordinate systems that the velocity data in .v1, .v2 and .v3 are measured in: Beam, XYZ or ENU. The coordinate system selected during the deployment planning is indicated in the .hdr file.

The three relevant coordinate systems. The figure shows an AWAC, but this applies to the other instruments as well.

Each instrument has its own unique transformation matrix, based on the transducer geometry. This matrix can be found, as previously mentioned, in the .hdr file generated when performing a binary data conversion in the software. Each row of the matrix represents a component in the instrument’s XYZ coordinate system, starting with X at the top row. Each column represents a beam. The third and fourth rows of the Vectrino or Signature transformation matrix represent the two estimates of vertical velocity (Z1 and Z2) produced by the instrument. XYZ coordinates are defined relative to the instrument, so they do not take into account heading, pitch and roll. ENU utilizes the attitude measurements to provide an Earth-relative coordinate system.

** **

**Beam to XYZ:**

The transformation between beam and XYZ coordinates is done using the original T matrix listed in the header file. In matrix form (using MATLAB notation, so [ X; Y; Z ] is a column vector), the math is:

T * [ B1; B2; B3 ] = [ X; Y; Z ]

Taking the matrix inverse of T will get you back to Beam coordinates:

inv( T ) * [ X; Y; Z ] = [ B1; B2; B3 ]

For the Vectrino Profiler: The transformation matrix for the Vectrino Profiler range cells is stored in Config.ProbeCalibration_calibrationMatrix, with one row per cell. To get the calibration matrix in a more usable form for transforms, this can be used:

T = reshape( Config.ProbeCalibration_calibrationMatrix( cell, : ), 4, 4 )'

(NB: Note the transpose of the matrix.)

And to convert from XYZ to Beam:

inv( T ) * [ X; Y; Z1; Z2 ]

**Beam or XYZ to ENU:**

The transformation matrix must be recalculated every time the heading, pitch or roll changes, when selecting ENU coordinates.

The procedure is as follows:

- Find the transformation matrix in the .hdr file
- Scale the transformation matrix to floating point numbers if it has not been scaled already (i.e. has a value of several thousand). The scaling parameter is 4096.
- Check the orientation of the instrument (.sen file, status bit, bit 0; 0 = up-looking, 1 = down-looking). If the instrument is pointing down, rows 2 and 3 of the matrix must change sign.
- Make a heading matrix.
- Make a tilt matrix.
- Make a new transformation matrix (R), including the instrument transformation matrix, heading and tilt matrix (refer to the attached MATLAB script for details)
- Then:

[ E; N; U ] = R * [ B1; B2; B3 ]

[ B1; B2; B3 ] = inv(R) * [ E; N; U ]

[ E; N; U ] = R * inv(T) * [ X; Y; Z ]

[ X; Y; Z ] = T * inv(R) * [ E; N; U ]

Here is a MATLAB script describing how to do the transformation: MATLAB script

**4-beam ADCP velocities into ENU:**

The MATLAB script above can be used for 4-beam systems also, and a specific 4-beam Signature script is linked below. As seen from the script, the transform has two steps – one from beam to XYZ and the second from XYZ to ENU coordinates.

The first step is a little different for 4-beam systems:

Vx= (V1 – V3)/2*sin(20 deg)

Vy= (V2 – V4)/2*sin(20 deg)

Vz= (V1+V2+V3+V4)/4*cos(20 deg)

(This is for a 4-beam system with 20-degree beams, where the beams are numbered clockwise from Beam 1).

The next step from XYZ to ENU is the same as for 3-beam systems.

## Comments

0 comments

Please sign in to leave a comment.