Free cookie consent management tool by TermsFeed Policy Generator

source: branches/FitnessLandscapeAnalysis/VRPProblemAnalyzer/Utils.cs @ 9613

Last change on this file since 9613 was 7316, checked in by svonolfe, 13 years ago

Added Picture generator (#1696)

File size: 696 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5
6namespace VRPProblemAnalyzer {
7
8  public static class Utils {
9
10    public static List<PointD> MatrixToPointList(double[,] vertices) {
11      var points = new List<PointD>();
12      for (int i = 0; i < vertices.GetLength(0); i++) {
13        points.Add(new PointD(vertices[i, 0], vertices[i, 1]));
14      }
15      return points;
16    }
17
18    public static double GetDistance(double[,] vertices, int source, int target) {
19      return Math.Sqrt(
20        Math.Pow((vertices[source, 0] - vertices[target, 0]), 2) +
21        Math.Pow((vertices[source, 1] - vertices[target, 1]), 2));
22    }
23  }
24}
Note: See TracBrowser for help on using the repository browser.