remapCoordinateSystem method
Remaps the device coordinate system of this OrientationEvent to a new coordinate system defined by the specified 'newX' and 'newY' axes.
The 'newZ' axis is calculated as the cross product of 'newX' and 'newY'.
Throws an UnsupportedError if 'newX' and 'newY' are not orthogonal or if they are identical.
Returns a new OrientationEvent instance with the remapped coordinate system and updated quaternion representing the orientation in the new system.
Implementation
OrientationEvent remapCoordinateSystem(Axis3 newX, Axis3 newY) {
final newZ = newX.cross(newY);
if (newZ.length2 != 1) {
throw UnsupportedError(
'The specified axes for newX and newY are not orthogonal or are '
'identical. Please specify two different, non-parallel axes that are '
'orthogonal to each other.',
);
}
final transformMatrix = Matrix3.columns(newX, newY, newZ);
return OrientationEvent._(
quaternion.multiply(transformMatrix.toQuaternion()),
accuracy,
timestamp,
coordinateSystem.multiply(transformMatrix),
);
}