Exemplo n.º 1
0
 public static MyVector operator *(MyVector v1, MyVector v2)
 {
     MyVector d = new MyVector(v1.y * v2.z - v2.z * v2.y,
         v1.z * v2.x - v1.x * v2.z,
         v1.x * v2.y - v1.y * v2.x);
     return d;
 }
Exemplo n.º 2
0
 public static MyVector operator /(MyVector v, double k)
 {
     MyVector d=new MyVector(v.x / k, v.y / k, v.z / k) ;
     d.x =v.x / k;
     d.y =v.y / k;
     d.z =v.z / k;
     return d;
 }
Exemplo n.º 3
0
 /// <summary>  
 /// 求向量  
 /// </summary>  
 /// <param name="v1"></param>  
 /// <param name="v2"></param>  
 /// <returns></returns>          
 public static MyVector operator -(MyVector v1, MyVector v2)
 {
     MyVector d = new MyVector(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
     return d;
 }
Exemplo n.º 4
0
 /// <summary>  
 /// 求反向量  
 /// </summary>  
 /// <param name="v">向量</param>  
 /// <returns>新向量</returns>  
 public static MyVector operator -(MyVector v)
 {
     MyVector d = new MyVector(-v.x, -v.y, -v.z);
     return d;
 }
Exemplo n.º 5
0
 /// <summary>  
 /// 向量和  
 /// </summary>  
 /// <param name="v1">向量1</param>  
 /// <param name="v2">向量2</param>  
 /// <returns>新向量</returns>  
 public static MyVector operator +(MyVector v1, MyVector v2)
 {
     MyVector d = new MyVector(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
     return d;
 }
Exemplo n.º 6
0
 public static MyVector operator *(double k, MyVector v)
 {
     MyVector d = new MyVector(k * v.x, k * v.y, k * v.z);
     return d;
 }
Exemplo n.º 7
0
 /// <summary>  
 /// 求单位向量  
 /// </summary>  
 /// <returns></returns>  
 public MyVector normal()
 {
     double k = 1 / magnitude();
     MyVector d = new MyVector(k * x, k * y, k * z);
     return d;
 }