/*
The MIT License (MIT)

Copyright (c) 2015 Thorsten Wagner (wagner@biomedical-imaging.de)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

package de.biomedical_imaging.traJ;

import java.util.ArrayList;

import javax.vecmath.Point3d;

public  class Trajectory extends ArrayList<Point3d> {
	
	private int dimension;
	private long id;
	private static long idCounter=1; 
	public Trajectory(int dimension) {
		this.dimension = dimension;
		id = idCounter++;
	}
	
	public double[][] getPositionsAsArray(){
		double[][] posAsArr = new double[size()][3];
		for(int i = 0; i < size(); i++){
			if(get(i)!=null){
				posAsArr[i][0] = get(i).x;
				posAsArr[i][1] = get(i).y;
				posAsArr[i][2] = get(i).z;
			}
			else{
				posAsArr[i] = null;
			}
		}
		return posAsArr;
	}
	
	@Override
	public String toString() {
		String result="";
		for(int i = 0; i < size(); i++){
			result += " x: "+   get(i).x + " y: " +  get(i).y + " z: " + get(i).z + "\n";
		}
		return result;
	}
	
	@Override
	/**
	 * Adds an position the trajectory. Between two position should the same timelag.
	 * If there is a gap in the trajectory, please add null.
	 * @param pos The next position of the trajectory. Add null for a gap.
	 */
	public boolean add(Point3d e) {
		// TODO Auto-generated method stub
		return super.add(e);
	}
	
	public int getDimension(){
		return dimension;
	}
	
	public long getID(){
		return id;
	}
	
}

@@ -1208,16 +1208,46 @@
 Point3d;
+%0Aimport javax.vecmath.Point4d;
 %0A%0Apublic
@@ -1320,16 +1320,53 @@
 ension;%0A
+%09private int relativeStartTimepoint;%0A
 %09private
@@ -1476,16 +1476,221 @@
 ension;%0A
+%09%09relativeStartTimepoint = 0;%0A%09%09id = idCounter++;%0A%09%7D%0A%09%0A%09public Trajectory(int dimension, int relativeStartTimepoint) %7B%0A%09%09this.dimension = dimension;%0A%09%09this.relativeStartTimepoint = relativeStartTimepoint;%0A
 %09%09id = i
@@ -2560,86 +2560,457 @@
 lic 
-int getDimension()%7B%0A%09%09return dimension;%0A%09%7D%0A%09%0A%09public long getID()%7B%0A%09%09return id
+boolean add(double x, double y, double z)%7B%0A%09%09return super.add(new Point3d(x, y, z));%0A%09%7D%0A%09%0A%09public void scale(double s)%7B%0A%09%09for( int i = 0; i %3C size(); i++)%7B%0A%09%09%09get(i).scale(s);%0A%09%09%7D%0A%09%7D%0A%09%0A%09%0A%09public int getDimension()%7B%0A%09%09return dimension;%0A%09%7D%0A%09%0A%09public long getID()%7B%0A%09%09return id;%0A%09%7D%0A%09%0A%09public int getRelativeStartTimepoint()%7B%0A%09%09return relativeStartTimepoint;%0A%09%7D%0A%09%0A%09public void setRelativStartTimepoint(int timepoint)%7B%0A%09%09relativeStartTimepoint = timepoint
 ;%0A%09%7D

Add scale