/// <summary> /// Calculates the length or magnitude of the given vector. /// </summary> /// <param name="vector">The vector to calculate the length from.</param> /// <returns>The length of the given vector.</returns> public static decimal CalcLength(Vect2 vector) { return((decimal)Math.Sqrt(((double)vector.X * (double)vector.X) + ((double)vector.Y * (double)vector.Y))); }
/// <summary> /// Calculates the dot product of the given vectors. /// </summary> /// <param name="start">The starting vector.</param> /// <param name="end">The ending vector.</param> /// <returns>The scalar dot product value of the start and end vectors.</returns> public static decimal DotProduct(Vect2 start, Vect2 end) { //Dot Product Ref: https://www.mathsisfun.com/algebra/vectors-dot-product.html return((start.X * end.X) + (start.Y * end.Y)); }