Ejemplo n.º 1
0
 public static Vector2D Lerp(Vector2D value1, Vector2D value2, float amount)
 {
     Vector2D vector2 = new Vector2D();
     vector2.X = value1.X + (value2.X - value1.X) * amount;
     vector2.Y = value1.Y + (value2.Y - value1.Y) * amount;
     return vector2;
 }
Ejemplo n.º 2
0
 // add this vector with the parameter vector
 // and return the result
 public Vector2D Add(Vector2D Vec)
 {
     Vector2D NewVec = new Vector2D();
     NewVec.X = X + Vec.X;
     NewVec.Y = Y + Vec.Y;
     return NewVec;
 }
Ejemplo n.º 3
0
 // find the angle between this vector and the parameter vector
 public double AngleTo(Vector2D Vec)
 {
     double AdotB = DotProduct(Vec);
     double ALstarBL = Length() * Vec.Length();
     if (ALstarBL == 0)
     {
         return 0.0;
     }
     return 180.0 / Math.PI * System.Math.Acos(AdotB / ALstarBL);
 }
Ejemplo n.º 4
0
 // translate the current matrix
 public void SetToTranslation(Vector2D TransVec)
 {
     matrix.SetValue(TransVec.X, 0, 2);
     matrix.SetValue(TransVec.Y, 1, 2);
 }
Ejemplo n.º 5
0
 // translate this point by the parameter vector
 public void TranslateBy(Vector2D Vec)
 {
     //if Vec.Length() > 1.0 Then
     X = X + Vec.X;
     Y = Y + Vec.Y;
     //End if
 }
Ejemplo n.º 6
0
 public Vector2D Divide(Double Value)
 {
     Vector2D newvec = new Vector2D();
     newvec.X = X / Value;
     newvec.Y = Y / Value;
     return newvec;
 }
Ejemplo n.º 7
0
 // find the unit vector and return it
 public Vector2D UnitVector()
 {
     Vector2D Vec = new Vector2D();
     double len = Length();
     if (len == 0.0)
     {
         Vec.SetVector(0.0, 0.0);
         return Vec;
     }
     Vec.X = X / len;
     Vec.Y = Y / len;
     return Vec;
 }
Ejemplo n.º 8
0
 // copy constructor
 public Vector2D(Vector2D Vec)
 {
     X = Vec.X;
     Y = Vec.Y;
 }
Ejemplo n.º 9
0
 public Vector2D Multiply(Double Value)
 {
     Vector2D newvec = new Vector2D();
     newvec.X = X * Value;
     newvec.Y = Y * Value;
     return newvec;
 }
Ejemplo n.º 10
0
 // subtract this vector with the parameter vector
 // and return the result
 public Vector2D Subtract(Vector2D Vec)
 {
     Vector2D NewVec = new Vector2D();
     NewVec.X = X - Vec.X;
     NewVec.Y = Y - Vec.Y;
     return NewVec;
 }
Ejemplo n.º 11
0
 // checks whether this vector is perpendicular to the parameter vector
 public Boolean IsPerpendicularTo(Vector2D Vec)
 {
     double Ang = AngleTo(Vec);
     if (Ang == (90 * System.Math.PI / 180.0)) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 12
0
 // checks whether this vector is parallel to the parameter vector
 public Boolean IsParallelTo(Vector2D Vec)
 {
     Vector2D Vec1 = UnitVector();
     Vector2D Vec2 = Vec.UnitVector();
     if ((Vec1.X == Vec2.X && Vec1.Y == Vec2.Y) || (Vec1.X == -Vec2.X && Vec1.Y == -Vec2.Y)) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 13
0
 // checks whether this vector is equal to the parameter vector
 public Boolean IsEqualTo(Vector2D Vec)
 {
     if (X == Vec.X && Y == Vec.Y) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 14
0
 // checks whether this vector is codirectional to the parameter vector
 public Boolean IsCodirectionalTo(Vector2D Vec)
 {
     Vector2D Vec1 = UnitVector();
     Vector2D Vec2 = Vec.UnitVector();
     if (Vec1.X == Vec2.X && Vec1.Y == Vec2.Y) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 15
0
 // dot product of this vector and the parameter vector
 public double DotProduct(Vector2D Vec)
 {
     return (X * Vec.X) + (Y * Vec.Y);
 }