Example #1
0
        /// <summary>
        /// Calculate Euclidean distance between two points.
        /// </summary>
        /// 
        /// <param name="anotherPoint">Point to calculate distance to.</param>
        /// 
        /// <returns>Returns Euclidean distance between this point and
        /// <paramref name="anotherPoint"/> points.</returns>
        /// 
        public double DistanceTo(DoublePoint anotherPoint)
        {
            double dx = X - anotherPoint.X;
            double dy = Y - anotherPoint.Y;

            return System.Math.Sqrt(dx * dx + dy * dy);
        }
Example #2
0
        /// <summary>
        /// Calculate squared Euclidean distance between two points.
        /// </summary>
        /// 
        /// <param name="anotherPoint">Point to calculate distance to.</param>
        /// 
        /// <returns>Returns squared Euclidean distance between this point and
        /// <paramref name="anotherPoint"/> points.</returns>
        /// 
        public double SquaredDistanceTo(DoublePoint anotherPoint)
        {
            double dx = X - anotherPoint.X;
            double dy = Y - anotherPoint.Y;

            return dx * dx + dy * dy;
        }
Example #3
0
 /// <summary>
 /// Division operator - divides coordinates of the specified point by scalar value.
 /// </summary>
 /// 
 /// <param name="point">Point to divide coordinates of.</param>
 /// <param name="factor">Division factor.</param>
 /// 
 /// <returns>Returns new point which coordinates equal to coordinates of
 /// the specified point divided by specified value.</returns>
 /// 
 public static DoublePoint Divide(DoublePoint point, double factor)
 {
     return new DoublePoint(point.X / factor, point.Y / factor);
 }
Example #4
0
 /// <summary>
 /// Subtraction operator - subtracts scalar from the specified point.
 /// </summary>
 /// 
 /// <param name="point">Point to decrease coordinates of.</param>
 /// <param name="valueToSubtract">Value to subtract from coordinates of the specified point.</param>
 /// 
 /// <returns>Returns new point which coordinates equal to coordinates of
 /// the specified point decreased by specified value.</returns>
 /// 
 public static DoublePoint Subtract(DoublePoint point, double valueToSubtract)
 {
     return new DoublePoint(point.X - valueToSubtract, point.Y - valueToSubtract);
 }
Example #5
0
 /// <summary>
 /// Multiplication operator - multiplies coordinates of the specified point by scalar value.
 /// </summary>
 /// 
 /// <param name="point">Point to multiply coordinates of.</param>
 /// <param name="factor">Multiplication factor.</param>
 /// 
 /// <returns>Returns new point which coordinates equal to coordinates of
 /// the specified point multiplied by specified value.</returns>
 ///
 public static DoublePoint Multiply(DoublePoint point, double factor)
 {
     return new DoublePoint(point.X * factor, point.Y * factor);
 }
Example #6
0
 /// <summary>
 /// Subtraction operator - subtracts values of two points.
 /// </summary>
 /// 
 /// <param name="point1">Point to subtract from.</param>
 /// <param name="point2">Point to subtract.</param>
 /// 
 /// <returns>Returns new point which coordinates equal to difference of corresponding
 /// coordinates of specified points.</returns>
 ///
 public static DoublePoint Subtract(DoublePoint point1, DoublePoint point2)
 {
     return new DoublePoint(point1.X - point2.X, point1.Y - point2.Y);
 }
Example #7
0
 /// <summary>
 /// Addition operator - adds scalar to the specified point.
 /// </summary>
 /// 
 /// <param name="point">Point to increase coordinates of.</param>
 /// <param name="valueToAdd">Value to add to coordinates of the specified point.</param>
 /// 
 /// <returns>Returns new point which coordinates equal to coordinates of
 /// the specified point increased by specified value.</returns>
 /// 
 public static DoublePoint Add(DoublePoint point, double valueToAdd)
 {
     return new DoublePoint(point.X + valueToAdd, point.Y + valueToAdd);
 }
Example #8
0
 /// <summary>
 /// Division operator - divides coordinates of the specified point by scalar value.
 /// </summary>
 ///
 /// <param name="point">Point to divide coordinates of.</param>
 /// <param name="factor">Division factor.</param>
 ///
 /// <returns>Returns new point which coordinates equal to coordinates of
 /// the specified point divided by specified value.</returns>
 ///
 public static DoublePoint Divide(DoublePoint point, double factor)
 {
     return(new DoublePoint(point.X / factor, point.Y / factor));
 }
Example #9
0
 /// <summary>
 /// Addition operator - adds values of two points.
 /// </summary>
 /// 
 /// <param name="point1">First point for addition.</param>
 /// <param name="point2">Second point for addition.</param>
 /// 
 /// <returns>Returns new point which coordinates equal to sum of corresponding
 /// coordinates of specified points.</returns>
 /// 
 public static DoublePoint Add(DoublePoint point1, DoublePoint point2)
 {
     return new DoublePoint(point1.X + point2.X, point1.Y + point2.Y);
 }
Example #10
0
 /// <summary>
 /// Multiplication operator - multiplies coordinates of the specified point by scalar value.
 /// </summary>
 ///
 /// <param name="point">Point to multiply coordinates of.</param>
 /// <param name="factor">Multiplication factor.</param>
 ///
 /// <returns>Returns new point which coordinates equal to coordinates of
 /// the specified point multiplied by specified value.</returns>
 ///
 public static DoublePoint Multiply(DoublePoint point, double factor)
 {
     return(new DoublePoint(point.X * factor, point.Y * factor));
 }
Example #11
0
 /// <summary>
 /// Subtraction operator - subtracts scalar from the specified point.
 /// </summary>
 ///
 /// <param name="point">Point to decrease coordinates of.</param>
 /// <param name="valueToSubtract">Value to subtract from coordinates of the specified point.</param>
 ///
 /// <returns>Returns new point which coordinates equal to coordinates of
 /// the specified point decreased by specified value.</returns>
 ///
 public static DoublePoint Subtract(DoublePoint point, double valueToSubtract)
 {
     return(new DoublePoint(point.X - valueToSubtract, point.Y - valueToSubtract));
 }
Example #12
0
 /// <summary>
 /// Addition operator - adds scalar to the specified point.
 /// </summary>
 ///
 /// <param name="point">Point to increase coordinates of.</param>
 /// <param name="valueToAdd">Value to add to coordinates of the specified point.</param>
 ///
 /// <returns>Returns new point which coordinates equal to coordinates of
 /// the specified point increased by specified value.</returns>
 ///
 public static DoublePoint Add(DoublePoint point, double valueToAdd)
 {
     return(new DoublePoint(point.X + valueToAdd, point.Y + valueToAdd));
 }
Example #13
0
 /// <summary>
 /// Subtraction operator - subtracts values of two points.
 /// </summary>
 ///
 /// <param name="point1">Point to subtract from.</param>
 /// <param name="point2">Point to subtract.</param>
 ///
 /// <returns>Returns new point which coordinates equal to difference of corresponding
 /// coordinates of specified points.</returns>
 ///
 public static DoublePoint Subtract(DoublePoint point1, DoublePoint point2)
 {
     return(new DoublePoint(point1.X - point2.X, point1.Y - point2.Y));
 }
Example #14
0
 /// <summary>
 /// Addition operator - adds values of two points.
 /// </summary>
 ///
 /// <param name="point1">First point for addition.</param>
 /// <param name="point2">Second point for addition.</param>
 ///
 /// <returns>Returns new point which coordinates equal to sum of corresponding
 /// coordinates of specified points.</returns>
 ///
 public static DoublePoint Add(DoublePoint point1, DoublePoint point2)
 {
     return(new DoublePoint(point1.X + point2.X, point1.Y + point2.Y));
 }