public void Normalize() { IVector <DoubleComponent> Point3 = MatrixFactory <DoubleComponent> .CreateVector3D(3, -4, 5); Point3 = Point3.Normalize(); Assert.IsTrue(Point3.GetMagnitude().GreaterThan(0.99) && Point3.GetMagnitude().LessThan(1.01)); }
//checks to see if the minesweeper has 'collected' a mine public int CheckForMine(List <IVector <T> > mines, T size) { IVector <T> DistToObject = m_vPosition.Subtract(mines[m_iClosestMine]); if (DistToObject.GetMagnitude().LessThan(size.Add(5))) { return(m_iClosestMine); } return(-1); }
public static IVector <T> Normalize <T>(this IVector <T> vector) where T : IEquatable <T>, IComparable <T>, IComputable <T>, IConvertible, IFormattable, ICommonNumericalOperations <T>, ITrigonometricOperations <T> { T length = vector.GetMagnitude(); if (length.NotEqual(0)) { return(MatrixFactory <T> .CreateVector3D(vector[0].Divide(length), vector[1].Divide(length), vector[2].Divide(length))); } return(MatrixFactory <T> .CreateZeroVector(VectorDimension.Three)); }