Пример #1
0
 //overloading - operator
 public static Vector operator -(Vector a, Vector b)
 {
     Vector tmp = new Vector();
     tmp.Xvalue = a.Xvalue - b.Xvalue;
     tmp.Yvalue = a.Yvalue - b.Yvalue;
     return tmp;
 }
Пример #2
0
 //method to calculate the magnitude of a vector object
 public double magnitude(Vector a)
 {
     double d = 0;
     d = a.Xvalue  * a.Xvalue + a.Yvalue * a.Yvalue;
     d = Math.Sqrt(d);
     return d;
 }
Пример #3
0
 //method to calculate the "Distance" between two vector objects
 public double Distance(Vector a, Vector b)
 {
     double d = 0;
     d = (a.Xvalue - b.Xvalue) * (a.Xvalue - b.Xvalue) + (a.Yvalue - b.Yvalue) * (a.Yvalue - b.Yvalue);
     d = Math.Sqrt(d);
     return d;
 }