Esempio n. 1
0
        /// <summary>
        /// A method to calculate the distance between this
        /// voxel and the given coordinates of type T.
        /// </summary>
        /// <param name="x">A x-coordinate of type T</param>
        /// <param name="y">A y-coordinate of type T</param>
        /// <param name="z">A z-coordinate of type T</param>
        /// <returns>The distance between this voxel and the given coordinates.</returns>
        public T DistanceTo(T x, T y, T z)
        {
            #region Initial Checks

            if (x == null)
            {
                throw new ArgumentNullException("The given x-coordinate must not be null!");
            }

            if (y == null)
            {
                throw new ArgumentNullException("The given y-coordinate must not be null!");
            }

            if (z == null)
            {
                throw new ArgumentNullException("The given z-coordinate must not be null!");
            }

            #endregion

            var dX = Math.Distance(X, x);
            var dY = Math.Distance(Y, y);
            var dZ = Math.Distance(Z, z);

            return(Math.Sqrt(Math.Add(Math.Mul(dX, dX), Math.Mul(dY, dY), Math.Mul(dZ, dZ))));
        }
Esempio n. 2
0
 /// <summary>
 /// A method to calculate the square root of the vector.
 /// </summary>
 /// <param name="v">A vector.</param>
 /// <returns>The square root of v: Sqrt(v)</returns>
 public IVector2D <T> Sqrt(IVector2D <T> v)
 {
     return(new Vector2D <T>(Math.Sqrt(v.X),
                             Math.Sqrt(v.Y)));
 }