rotate method Null safety
- Vector3 v
Rotates v
by this.
Implementation
Vector3 rotate(Vector3 v) {
// conjugate(this) * [v,0] * this
final _w = _qStorage[3];
final _z = _qStorage[2];
final _y = _qStorage[1];
final _x = _qStorage[0];
final tiw = _w;
final tiz = -_z;
final tiy = -_y;
final tix = -_x;
final tx = tiw * v.x + tix * 0.0 + tiy * v.z - tiz * v.y;
final ty = tiw * v.y + tiy * 0.0 + tiz * v.x - tix * v.z;
final tz = tiw * v.z + tiz * 0.0 + tix * v.y - tiy * v.x;
final tw = tiw * 0.0 - tix * v.x - tiy * v.y - tiz * v.z;
final result_x = tw * _x + tx * _w + ty * _z - tz * _y;
final result_y = tw * _y + ty * _w + tz * _x - tx * _z;
final result_z = tw * _z + tz * _w + tx * _y - ty * _x;
final vStorage = v.storage;
vStorage[2] = result_z;
vStorage[1] = result_y;
vStorage[0] = result_x;
return v;
}