static public CTTrajectory<Double> cutTrajectory(CTTrajectory<Double> trj, double cutPercentage) //? TODO test
			throws IllegalArgumentException {

		if( trj == null)
			throw new IllegalArgumentException("Error: null trajectory");
		if( trj.getTransitionsNumber() == 0)
			throw new IllegalArgumentException("Error: empty trajectory (name = " + trj.getName() + ")");
		if( cutPercentage <= 0 || cutPercentage > 1)
			throw new IllegalArgumentException("Error: the cutting percentage must be in (0,1]");
		
		// Searching of the last transition to keep
		double tMax = trj.getTransitionTime( trj.getTransitionsNumber() - 1) * cutPercentage;
		int iMin = 0; 
		int iMax = trj.getTransitionsNumber() - 1;
		while( iMin <= iMax) {
			int i = iMin + (iMax - iMin)/2;
			CTTransition<Double> trans = trj.getTransition(i);
			
			if( trans.getTime() < tMax)
				iMin = i + 1;
			else if( trans.getTime() > tMax)			
				iMax = i - 1;
			else {
				iMax = i;
				iMin = i+1;
			}
		}
		CTTransition<Double> lastTrans = trj.getTransition(iMax);
		
		// Transition of the new trajectory
		List<CTTransition<Double>> trjList = trj.transitions.subList(0, iMax + 1);
		if( lastTrans.getTime() != tMax) {		// define the termination point
			String[] values = new String[trj.nodeIndexing.getNodesNumber()];
			for(int i = 0; i < trj.nodeIndexing.getNodesNumber(); ++i)
				values[i] =  lastTrans.getNodeValue(i);
			
			trjList.add(new CTTransition<Double>(trj.nodeIndexing, tMax, values));
		}
		
		// New trajectory generation
		CTTrajectory<Double> newTrj = new CTTrajectory<Double>(trj.nodeIndexing);
		newTrj.setTransisions( trjList);
		newTrj.setName( trj.getName());
		
		return newTrj;
	}