applyMatrix3 method

Vec3 applyMatrix3(
  1. Mat33 m, [
  2. bool transpose = false
])

Apply a 3x3 Matrix to this vector

Implementation

Vec3 applyMatrix3 (Mat33 m, [bool transpose = false]) {
  double x = this.x, y = this.y, z = this.z;
  List<double> e = m.elements;

  if( transpose ){
    this.x = e[ 0 ] * x + e[ 1 ] * y + e[ 2 ] * z;
    this.y = e[ 3 ] * x + e[ 4 ] * y + e[ 5 ] * z;
    this.z = e[ 6 ] * x + e[ 7 ] * y + e[ 8 ] * z;
  }
  else {
    this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z;
    this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z;
    this.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z;
  }

  return this;
}