public static NonUnitVector CrossProduct(UnitVector v1, NonUnitVector v2) { return(new NonUnitVector( v1.Y * v2.Z - v1.Z * v2.Y, v1.Z * v2.X - v1.X * v2.Z, v1.X * v2.Y - v1.Y * v2.X )); }
public static UnitVector UnsafeCreateUnitVector(NonUnitVector v) { #if DEBUG var ms = v.MagnitudeSquared; if (ms < 0.99 || ms > 1.01) { throw new InvalidOperationException($"UnsafeCreateUnitVector({v}) has magnitude-squared of {ms}."); } #endif return(new UnitVector(v.X, v.Y, v.Z)); }
public Point Translate(NonUnitVector v) { return(new Point(X + v.X, Y + v.Y, Z + v.Z)); }
public Ray Translate(NonUnitVector v) { return(new Ray(RayOrigin.Translate(v), RayDirection)); }
public static UnitVector Normalize(this NonUnitVector v) { var mag = v.Magnitude; return(UnitVector.UnsafeCreateUnitVector(v.X / mag, v.Y / mag, v.Z / mag)); }
public static double DotProduct(NonUnitVector v1, UnitVector v2) { return(v1.X * v2.X + v1.Y * v2.Y + v1.Z * v2.Z); }