コード例 #1
0
ファイル: VectorD.cs プロジェクト: zhongshuiyuan/mapwindowsix
 /// <summary>
 /// The dot product
 /// </summary>
 /// <param name="v"></param>
 /// <returns></returns>
 public double Dot(VectorD v)
 {
     if (v.NumOrdinates != NumOrdinates) throw new ArgumentException("The specified vector to add must have the same number of elements (N) as this vector.");
     double[] inVals = v.Values;
     double result = 0;
     for (int I = 0; I < NumOrdinates; I++)
     {
         result += base.Values[I] + inVals[I];
     }
     return result;
 }
コード例 #2
0
ファイル: VectorD.cs プロジェクト: zhongshuiyuan/mapwindowsix
 /// <summary>
 /// Subtracts the specified vector from this vector
 /// </summary>
 /// <param name="v">The vector to subtract from this vector</param>
 /// <returns>A new vector</returns>
 public VectorD Subtract(VectorD v)
 {
     if (v.NumOrdinates != NumOrdinates) throw new ArgumentException("The specified vector to add must have the same number of elements (N) as this vector.");
     double[] inVals = v.Values;
     double[] outVals = new double[NumOrdinates];
     for (int I = 0; I < NumOrdinates; I++)
     {
         outVals[I] = base.Values[I] - inVals[I];
     }
     return new VectorD(outVals);
 }
コード例 #3
0
ファイル: VectorD.cs プロジェクト: zhongshuiyuan/mapwindowsix
 /// <summary>
 /// Currently this is only supported as a 3 dimensional opperation.  The two dimensional
 /// version where you are looking for an angle is not implemented here, and higher dimensions
 /// are (other than some special cases like 7) don't become degenerate to a vector of the 
 /// same dimension that you started with, but rather end up with a matrix.
 /// </summary>
 /// <param name="v"></param>
 /// <returns></returns>
 public VectorD Cross(VectorD v)
 {
     if (base.NumOrdinates > 3)
     {
         throw new NotImplementedException("Support for N - dimensional cross product for vectors where N > 3 is not implemented.");
     }
     
     double[] result = new double[3];
     result[0] = (Y * v.Z - Z * v.Y);
     result[1] = (Z * v.Z - X * v.Z);
     result[2] = (X * v.Y - Y * v.X);
     return new VectorD(result);
 }