cross method

Vec3 cross(
  1. Vec3 a, [
  2. Vec3? b
])

Cross a with this vector if b is provided cross a with b

Implementation

Vec3 cross(Vec3 a, [Vec3? b ]) {
  if ( b != null ) return crossVectors( a, b );

  double x = this.x, y = this.y, z = this.z;

  this.x = y * a.z - z * a.y;
  this.y = z * a.x - x * a.z;
  this.z = x * a.y - y * a.x;

  return this;
}