public static void TwoDemsion() { TwoDPoint[] Points = new TwoDPoint[100]; Random rdn = new Random(); for (int i = 0; i < Points.Length; i++) { Points[i] = new TwoDPoint(rdn.Next(1, 101), rdn.Next(1, 101)); } Util.CompareVector(Points); }
public static double CalculateVector(TwoDPoint first, TwoDPoint second) { if (second.xCord > first.xCord) { int temp = first.xCord; first.xCord = second.xCord; second.xCord = temp; } int width = first.xCord - second.xCord; if (second.yCord > first.yCord) { int temp = first.yCord; first.yCord = second.yCord; second.yCord = temp; } int height = first.yCord - second.yCord; double result = Math.Sqrt(Math.Pow(width, 2) + Math.Pow(height, 2)); return(result); }