Matrix Math - theRAPTLab/gsgo GitHub Wiki

To refresh our memory on matrix operations in computer graphics, a free online reference is Intro to Computer Graphics

From bottom of this page, this is the 2D transform:

TRANSLATE   SCALE       ROTATE

1 0 a       a 0 0       cos(d) -sin(d) 0
0 1 b       0 b 0       sin(d)  cos(d) 0
0 0 1       0 0 1       0       0      1

Matrices can be combined into a single matrix through matrix multiplication, but the order of application of the transforms is read from LAST TRANSFORM to FIRST. Because Math.

In general, our objects are defined around a local origin of (0,0) which is also the point of rotation. The order of operations to plot a local origin to point X,Y is to SCALE, ROTATE, TRANSLATE.

PTRACK NORMALIZATION

The PTrack system produces coordinates within a space where the origin and axis rotation must be experimentally determnined after mapping the bounds of the space. DevTracker will be used to determine and save the translation information.

PTrack Calibration Steps

Based on How to Calibrate wiki for PLAE

  1. offset x, y - Set the Origin - Have someone in the space as a "marker". Have the marker stand where you want "dead center" to be. This will be the origin 0,0. Adjust offset X,Y until the dot is at 0,0. MARK WITH TAPE so you can find the origin later.

  2. rot z - Set Rotation - Have the marker walk left and right in a straight line, parallel to the screen. If the marker is rotated, adjust the ROTATION value until it is correct.

  3. scale x,y - Set Coverage - Have 4 markers stand at each corner of the usable space. We want to map them to the 4 corners of the tracker utility by adjusting the X and Y scale values. MARK where each marker was standing with floor tape.

  4. With the space defined, you may find it useful to accurately MARK X and Y AXIS with floor tape.

Normalization Algorithm

PTrack coordinates are converted to normalized coordinates with range [-1, 1] (axis type). Coordinates that are within [-1,1] are considered within the simulation bounds, though it is possible for PTrack to produce values outside this range. The system may want to plot markers outside the simulation bounds to have kids queue up outside the marked space.

They are applied in the same order we calibrate the system: translate -> rotate -> scale

Reference Algorithm is in PLAE in step/input.js

  • The client-side PTRACK module just forwards the track data from UDP. This is raw coordinates.
  • raw PTRACK data is transformed by m_transform.matrix_align in m_TransformAndUpdate( entity, trackerObj )
  • matrix_align is set in m_UpdateLocationTransform(), which pulls the settings from m_transform and creates the matrix in this order
    • scale -> rotate -> translate

Again, the order is important: See this demo, and remember that the order of operations is read from right-to-left when interpreting a chain of matrix multiplications. In other words: M = Tr * Sc * Ro would create a matrix M that rotates, then scales, then translates.

Therefore in OUR scale -> rotate -> translate matrix, the effect is translate, rotate, then scale: the correct order for aligning the PTrack coordinate system. This is because each subsequent multiplication affects the previous one in entirety:

  • scale is the first operation
  • rotate is operating on scale
  • translate is operating on scale and rotate

This corresponds to doing the following operations one-by-one:

  • translate point
  • then rotate what you just translated
  • then scale what you just rotated and translated

This is the order of operations of the calibration procedure. To recreate it as a single matrix, M = S * R * T

DIZZYING! The important takewaway: just remember to evaluate pre-multiplied matrix operations from right to left.

⚠️ **GitHub.com Fallback** ⚠️