Get Distance between two vectors - CSharp System

CSharp examples for System:Math Geometry

Description

Get Distance between two vectors

Demo Code


using Microsoft.Xna.Framework;
using System;//from w  ww .j  av  a  2 s  .  c o  m

public class Main{
        public static double GetDistance(Vector2 startPoint, Vector2 endPoint)
        {
            var deltaX = Math.Abs(startPoint.X - endPoint.X);
            var deltaY = Math.Abs(startPoint.Y - endPoint.Y);
            var multi = deltaX*deltaX + deltaY*deltaY;
            return Math.Sqrt(multi);
        }
}

Related Tutorials