Esempio n. 1
0
 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));
        }
Esempio n. 3
0
 public Point Translate(NonUnitVector v)
 {
     return(new Point(X + v.X, Y + v.Y, Z + v.Z));
 }
Esempio n. 4
0
 public Ray Translate(NonUnitVector v)
 {
     return(new Ray(RayOrigin.Translate(v), RayDirection));
 }
Esempio n. 5
0
        public static UnitVector Normalize(this NonUnitVector v)
        {
            var mag = v.Magnitude;

            return(UnitVector.UnsafeCreateUnitVector(v.X / mag, v.Y / mag, v.Z / mag));
        }
Esempio n. 6
0
 public static double DotProduct(NonUnitVector v1, UnitVector v2)
 {
     return(v1.X * v2.X + v1.Y * v2.Y + v1.Z * v2.Z);
 }