/*
 * LengthMatrix.java
 *
 * Created on July 11, 2006, 1:28 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package cz.pcland.tsp;
import java.util.*;
/**
 *
 * @author petr
 */
public class LengthMatrix {
    public double data[][];
    
    /** Creates a new instance of LengthMatrix */
    public LengthMatrix() {
    }
    
   
    
    public void loadFromPositions(Vector positions){
        int len = positions.size();
        data = new double[len][len];
        System.out.println("positions are " + len + " len.");
        
        for(int i=0;i<len;i++){
            for(int j=0;j<len;j++){
                data[i][j] = Math.sqrt(
                    Math.pow(
                    TSPInstance.getCoordinates(positions, i).getX() -
                    TSPInstance.getCoordinates(positions, j).getX()
                    ,2) +
                    
                    Math.pow(TSPInstance.getCoordinates(positions, i).getY() -
                    TSPInstance.getCoordinates(positions, j).getY()
                    ,2)
                    );
            }
        }
    }
    
    
}
