Standard Euclidean distance between 2 points. - CSharp System

CSharp examples for System:Math Geometry

Description

Standard Euclidean distance between 2 points.

Demo Code


using System.Drawing;
using System;//from w w w  .  j a  v  a  2  s .co m

public class Main{
        /// <summary>
        /// Standard Euclidean distance between 2 points.
        /// </summary>
        public static double EuclideanDistance(Point a, Point b)
        {
            int dx = b.X - a.X;
            int dy = b.Y - a.Y;
            return Math.Sqrt((dx * dx) + (dy * dy));
        }
}

Related Tutorials