Ejemplo n.º 1
0
 public static double SumComponents(Vector v1)
 {
     return (v1.X + v1.Y);
 }
Ejemplo n.º 2
0
 public static Vector SqrComponents(Vector v1)
 {
     return
     (
        new Vector
        (
            v1.X * v1.X,
            v1.Y * v1.Y
        )
      );
 }
Ejemplo n.º 3
0
 public static Vector SqrtComponents(Vector v1)
 {
     return
     (
        new Vector
        (
           Math.Sqrt(v1.X),
           Math.Sqrt(v1.Y)
        )
     );
 }
Ejemplo n.º 4
0
 public Vector Max(Vector other)
 {
     return Max(this, other);
 }
Ejemplo n.º 5
0
 public static double Angle(Vector v1, Vector v2)
 {
     Vector a = Normalize(v1);
     Vector b = Normalize(v2);
     double angle = (Math.Atan2(a.Y, a.X) - Math.Atan2(b.Y, b.X));
     if (angle < 0)
     {
         angle += Math.PI * 2;
     }
     return
      (
         Math.Acos
         (
            Normalize(v1).DotProduct(Normalize(v2))
         )
      );
 }
Ejemplo n.º 6
0
 public double CrossProduct(Vector other)
 {
     return CrossProduct(this, other);
 }
Ejemplo n.º 7
0
 public Vector Interpolate(Vector other, double control)
 {
     return Interpolate(this, other, control);
 }
Ejemplo n.º 8
0
 public static bool IsPerpendicular(Vector v1, Vector v2)
 {
     return v1.DotProduct(v2) == 0;
 }
Ejemplo n.º 9
0
 public static bool IsUnitVector(Vector v1)
 {
     return v1.Length == 1;
 }
Ejemplo n.º 10
0
 public static double DotProduct(Vector v1, Vector v2)
 {
     return v1.X * v2.X + v1.Y + v2.Y;
 }
Ejemplo n.º 11
0
 public static Vector Interpolate(Vector v1, Vector v2, double control)
 {
     if (control > 1 || control < 0)
     {
         // Error message includes information about the actual value of the
         // argument
         throw new ArgumentOutOfRangeException
         (
            "Control Point must be between 0 and 1"
         );
     }
     else
     {
         return
         (
            new Vector
            (
                v1.X * (1 - control) + v2.X * control,
                v1.Y * (1 - control) + v2.Y * control
             )
         );
     }
 }
Ejemplo n.º 12
0
 public static double CrossProduct(Vector v1, Vector v2)
 {
     return v1.X * v2.Y - v1.Y * v2.X;
 }
Ejemplo n.º 13
0
 public static double AnglePI(Vector v1, Vector v2)
 {
     double angle = Angle2PI(v1, v2);
     if (angle > Math.PI)
     {
         angle = (2 * Math.PI) - angle;
     }
     return angle;
 }
Ejemplo n.º 14
0
 public static double Angle2PI(Vector v1, Vector v2)
 {
     Vector a = Normalize(v1);
     Vector b = Normalize(v2);
     double angle = (Math.Atan2(a.Y, a.X) - Math.Atan2(b.Y, b.X));
     if (angle < 0)
     {
         angle += Math.PI * 2;
     }
     return angle;
 }
Ejemplo n.º 15
0
 public static double SumComponentSqrs(Vector v1)
 {
     Vector v2 = SqrComponents(v1);
     return v2.SumComponents();
 }
Ejemplo n.º 16
0
 public static Vector Max(Vector v1, Vector v2)
 {
     if (v1 >= v2) { return v1; }
     return v2;
 }
Ejemplo n.º 17
0
 public double Angle(Vector other)
 {
     return Angle(this, other);
 }
Ejemplo n.º 18
0
 public static Vector Min(Vector v1, Vector v2)
 {
     if (v1 <= v2) { return v1; }
     return v2;
 }
Ejemplo n.º 19
0
 public double DotProduct(Vector other)
 {
     return DotProduct(this, other);
 }
Ejemplo n.º 20
0
 public static Vector Normalize(Vector v1)
 {
     // Check for divide by zero errors
     if (v1.Length == 0)
     {
         throw new DivideByZeroException("Magnitude for the Vector is currently 0");
     }
     else
     {
         // find the inverse of the vectors magnitude
         double inverse = 1 / v1.Length;
         return
         (
            new Vector
            (
             // multiply each component by the inverse of the magnitude
               v1.X * inverse,
               v1.Y * inverse
            )
         );
     }
 }
Ejemplo n.º 21
0
 public bool IsPerpendicular(Vector other)
 {
     return IsPerpendicular(this, other);
 }
Ejemplo n.º 22
0
 public static Vector PowComponents(Vector v1, double power)
 {
     return
     (
        new Vector
        (
           Math.Pow(v1.X, power),
           Math.Pow(v1.Y, power)
        )
     );
 }
Ejemplo n.º 23
0
 public Vector Min(Vector other)
 {
     return Min(this, other);
 }
Ejemplo n.º 24
0
 public static Double Abs(Vector v1)
 {
     return v1.Length;
 }