Get distance between two points : Geometry « Development Class « C# / C Sharp






Get distance between two points

         

using System;

namespace ComputationalGeometry.Shapes
{
    public static class MathUtility
    {
        /// <summary>
        /// Calculates the distance between two points.
        /// </summary>
        /// <param name="p1">First point.</param>
        /// <param name="p2">Second point.</param>
        /// <returns>The distance between two points.</returns>
        public static double GetDistance(Point2D p1, Point2D p2)
        {
            double xDelta = p1.X - p2.X;
            double yDelta = p1.Y - p2.Y;

            return Math.Sqrt(Math.Pow(xDelta, 2) + Math.Pow(yDelta, 2));
        }

    }
}

   
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Convert Meters To Inches
2.Convert Meters To Miles
3.Get Steps FromD istance And Stride
4.Convert Miles To Meters
5.Distance Util
6.PointD
7.Calculate Gradient Angle
8.Convert Meters To Feet
9.Tests if two line segments intersect or not.
10.Sorts a graph by the dependencies.
11.Degrees To Radians
12.Radians To Degrees
13.Angles Difference
14.Degrees To Radians and Radians To Degrees
15.Get Distance From Steps
16.Meter to feet and feet to Mile
17.Distance From Point To Line