Beispiel #1
0
        /// <summary>
        /// Get the direction of the vector, or throw an <see cref="Exception"/> if the vector is short.
        /// The length tolerance is set so that if a unit vector in 3D is projected into 2D, the projection is
        /// considered too short when the original vector would be considered perpendicular to the xy-plane.
        /// </summary>
        public static Direction2D GetDirection(DoubleVector2D vector)
        {
            var magnitude = vector.GetMagnitude();

            if (magnitude <= ZeroDotProductTolerance)
            {
                throw new ArgumentException("The vector is nearly zero.", nameof(vector));
            }
            return(new Direction2D(vector / magnitude));
        }
Beispiel #2
0
 private Direction2D(DoubleVector2D unitVector)
 {
     UnitVector = unitVector;
 }