Class: MatrixTracker<M>
Defined in: src/interaction/DynamicMatrix.ts:181
MatrixTracker — holds a live 2x2 or 3x3 matrix, the matrix analogue of ValueTracker.
It either stores a matrix directly (via the constructor or setMatrix) or computes one on every read from a getter (fromGetter) or from basis-vector sources (fromBasisVectors). Bind it to a grid or a 3D mobject with applyMatrixLive. The type parameter is the matrix size: pass a 3x3 matrix for a 3D tracker.
Example
const iPoint = new MovablePoint(scene, { point: [1, 0, 0] });
const jPoint = new MovablePoint(scene, { point: [0, 1, 0] });
const tracker = MatrixTracker.fromBasisVectors(iPoint, jPoint);
applyMatrixLive(plane, tracker, { onChange: () => scene.render() });
// 3D: a 3x3 tracker bound to a mesh in a ThreeDScene.
const tracker3d = new MatrixTracker<Matrix3x3>([[1, 0, 0], [0, 1, 0], [0, 0, 1]]);
applyMatrixLive(cube, tracker3d, { onChange: () => scene.render() });
Type Parameters
M
M extends LiveMatrix = Matrix2x2
Constructors
Constructor
new MatrixTracker<
M>(matrix):MatrixTracker<M>
Defined in: src/interaction/DynamicMatrix.ts:189
Create a tracker holding a fixed matrix.
Parameters
matrix
M = ...
The initial matrix. Default: the 2x2 identity.
Returns
MatrixTracker<M>
Methods
getColumns()
getColumns():
ColumnsOf<M>
Defined in: src/interaction/DynamicMatrix.ts:228
Get the column basis vectors of the current matrix.
Returns
ColumnsOf<M>
[i, j] for a 2x2 matrix (i = (a, c), j = (b, d)), or
[i, j, k] for a 3x3 matrix.
getMatrix()
getMatrix():
M
Defined in: src/interaction/DynamicMatrix.ts:198
Get the current matrix as a fresh copy.
Returns
M
The current matrix.
setColumns()
setColumns(...
columns):this
Defined in: src/interaction/DynamicMatrix.ts:219
Set the matrix from its column basis vectors.
Parameters
columns
...ColumnsInput<M>
The images of the basis vectors: i, j for a 2x2
matrix, i, j, k for a 3x3 matrix.
Returns
this
this for chaining.
setMatrix()
setMatrix(
matrix):this
Defined in: src/interaction/DynamicMatrix.ts:207
Set the matrix directly, dropping any getter source.
Parameters
matrix
M
The new matrix.
Returns
this
this for chaining.
transformPoint()
transformPoint(
point):ColumnOf<M>
Defined in: src/interaction/DynamicMatrix.ts:238
Map a point by the current matrix (about the origin).
Parameters
point
Readonly<ColumnOf<M>>
The point [x, y] (2x2) or [x, y, z] (3x3) to transform.
Returns
ColumnOf<M>
The transformed point, with the same size.
fromBasisVectors()
Call Signature
staticfromBasisVectors(iSource,jSource):MatrixTracker<Matrix2x2>
Defined in: src/interaction/DynamicMatrix.ts:265
Create a tracker whose matrix is built live from basis-vector sources. The columns follow the sources, so dragging a MovablePoint drives the matrix in real time. Two sources give a 2x2 matrix. Three sources give a 3x3 matrix.
Parameters
iSource
Source of the x basis vector image (first column).
jSource
Source of the y basis vector image (second column).
Returns
MatrixTracker<Matrix2x2>
A new MatrixTracker.
Call Signature
staticfromBasisVectors(iSource,jSource,kSource):MatrixTracker<Matrix3x3>
Defined in: src/interaction/DynamicMatrix.ts:269
Create a tracker whose matrix is built live from basis-vector sources. The columns follow the sources, so dragging a MovablePoint drives the matrix in real time. Two sources give a 2x2 matrix. Three sources give a 3x3 matrix.
Parameters
iSource
Source of the x basis vector image (first column).
jSource
Source of the y basis vector image (second column).
kSource
Source of the z basis vector image (third column, 3D only).
Returns
MatrixTracker<Matrix3x3>
A new MatrixTracker.
fromGetter()
staticfromGetter<M>(getter):MatrixTracker<M>
Defined in: src/interaction/DynamicMatrix.ts:249
Create a tracker whose matrix is recomputed from a getter on every read.
Type Parameters
M
M extends LiveMatrix
Parameters
getter
() => M
Returns the current matrix.
Returns
MatrixTracker<M>
A new MatrixTracker.