All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cogchar.animoid.calc.curvematrix.SharedDurationCACM Maven / Gradle / Ivy

/*
 *  Copyright 2011 by The Cogchar Project (www.cogchar.org).
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.cogchar.animoid.calc.curvematrix;

import org.appdapter.bind.math.jscience.number.NumberFactory;
import org.cogchar.animoid.calc.curve.*;
import org.cogchar.animoid.calc.optimize.ParameterVector;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.jscience.mathematics.function.Variable;
import org.jscience.mathematics.number.Real;
import org.jscience.mathematics.number.Number;
import org.jscience.mathematics.structure.Field;

/**
 *
 * @param  
 * @author Stu B. 
 */
public class SharedDurationCACM & Field> extends ConstAccelCurveMatrix {
	protected	List		myIntervals = new ArrayList();

	public SharedDurationCACM(NumberFactory numFact) {
		super(numFact);
	}
	public SDCACM_Interval appendInterval() {
		int		idx = myIntervals.size();
		String nameSuffix = "" + idx + 1;
		SDCACM_Interval interval = new SDCACM_Interval(idx, nameSuffix);
		Variable toffVar =  interval.getTimeOffsetVariable();
		Set curves = addAndCollectOneCurvePerSequence(toffVar, nameSuffix);
		interval.setCurveSet(curves);
		myIntervals.add(interval);
		return interval;
	}
	private Set addAndCollectOneCurvePerSequence(Variable timeOffsetVar, String nameSuffix) {
		Set curves = new HashSet();
		for (ConstAccelCurveSequence seq : getSequences()) {
			String seqName = seq.getName();
			String curveSymbolSuffix = seqName + "_" + nameSuffix;
			ConstAccelCurve curve = new ConstAccelCurve(curveSymbolSuffix, timeOffsetVar, myNumberFactory);
			seq.addStepCurve(curve);
			curves.add(curve);
		}
		return curves;
	}
	public void setDurations(ParameterVector durPV) {
		for (ConstAccelCurveSequence seq :getSequences()) {
			seq.setDurationParams(durPV);
		}
	}
	public List	getIntervals() {
		return myIntervals;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy