Calculate Distance 2D - CSharp System

CSharp examples for System:Math Geometry

Description

Calculate Distance 2D

Demo Code


using System;/*  w  ww. j  a  v  a2 s  .c  om*/

public class Main{
        public static double CalcDistance2D(double x1, double y1, double x2, double y2)
        {
            double deltaX = x1 - x2;
            double deltaY = y1 - y2;

            double distance = Math.Sqrt((deltaX * deltaX) + (deltaY * deltaY));

            return distance;
        }
}

Related Tutorials