@gov.nasa.jpl.honeycomb/frame-transformer
v0.0.6
Published
Utility for transforming between 3d frames using three.js.
Readme
frame-transformer
Helper functions for transforming matrices, vectors, and quaternions between frames.
Use
import { Matrix4, Vector3 } from 'three';
import { FrameTransformer } from '@gov.nasa.jpl.honeycomb/frame-transformer';
const
point = new Vector3(),
frameA = new Matrix4(),
frameB = new Matrix4();
// ...
// Transform a positon from frame A to frame B and write the result
// back into the point vector
FrameTransformer.transformPoint(frameA, frameB, point, point);API
FrameTransformer
Class with static methods for transforming between frames
transformFrame
static transformFrame(
fromFrame : Matrix4,
toFrame : Matrix4,
mat : Matrix4,
outputMat : Matrix4
) : voidTransforms the provided input matrix from being relative to the fromFrame to being
relative to the toFrame. The result is written to the output matrix. The input and
output matrices can be the same object.
transformPoint
static transformPoint(
fromFrame : Matrix4,
toFrame : Matrix4,
pos : Vector3,
outputVec : Vector3
) : voidSame as transformFrame but for points.
transformDirection
static transformDirection(
fromFrame : Matrix4,
toFrame : Matrix4,
dir : Vector3,
outputVec : Vector3
) : voidSame as transformFrame but for directions.
transformQuaternion
static transformQuaternion(
fromFrame : Matrix4,
toFrame : Matrix4,
quat : Quaternion,
outputQuat : Quaternion
) : voidSame as transformFrame but for quaternions.
constructor
constructor( fromFrame : Matrix4, toFrame : Matrix4 ) : voidThe FrameTransformer can be instantiated such that it will only transform between a fixed set
of frames. The instance retains the same static methods but they only take the input and the
output parameters.
Note that a reference to the passed matrices are saved so updates to them will effect results.
transformMatrix
transformMatrix( mat : Matrix4, output : Matrix4 ) : voidtransformPoint
transformPoint( pos : Vector3, output : Vector3 ) : voidtransformDirection
transformDirection( dir : Vector3, output : Vector3 ) : voidtransformQuaternion
transformQuaternion( quat : Quaternion, output : Quaternion ) : void