Calculate Distance for 2D points - CSharp System

CSharp examples for System:Math Geometry

Description

Calculate Distance for 2D points

Demo Code


using System;/*from  w  w  w. j  a  v  a2s .  c o m*/

public class Main{
        public static double CalcDistance2D(double x1, double y1, double x2, double y2)
        {
            double distance2D = Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
            return distance2D;
        }
}

Related Tutorials