package clothSimulator;

import java.util.LinkedList;
import java.util.List;

import javax.vecmath.Vector3d;

import annas.graph.WeightedInterface;

public class PinnedConstraint implements Constraint{

	// this is the particle which is being pinned
	Particle p1;
	private List<Particle> theParticles=new LinkedList<Particle>();
	//cLIndex is the index declaring where in the constraint List thic particular constraint lives
	private int cLIndex;
	//the current value of constraint
	double g;
	//the current values of the gradient of the constraint
	double Gp1x;
	double Gp1y;
	double Gp1z;
	//the current values of the first time derivative of the gradient of the constraint
	double GdotP1x;
	double GdotP1y;
	double GdotP1z;
	
	public PinnedConstraint(Particle p, double pos){
	
	}
	
	
	@Override
	public ConstraintType constraintType() {
		// TODO Auto-generated method stub
		return ConstraintType.PINNED;
	}
	
	@Override
	public void updateAll(){
		updateCurrent_G();
		updateCurrent_Gdot();
		updateCurrent_g();
	}

	@Override
	public void updateCurrent_G() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void updateCurrent_Gdot() {
		// TODO Auto-generated method stub
		this.GdotP1x=0;
		this.GdotP1y=0;
		this.GdotP1z=0;
		
	}

	@Override
	public void updateCurrent_g() {
		//just gets overridden by the particular dof constraint 
	}
	
	@Override
	public double GiDot(double[] in) {
		return 0;
	}
	
	@Override
	public void GtransiDot(double[] in, double[] out) {
		//just gets overridden by the particular dof constraint
	}
	
	//multiplying by Gdot of a pinned constraint should always return zero
	@Override
	public double GdotiDot(double[] in) {
		return 0;
	}

	@Override
	public void setCLIndex(int cLIndex) {
		this.cLIndex = cLIndex;
	}
	@Override
	public int getCLIndex() {
		// TODO Auto-generated method stub
		return cLIndex;
	}


	@Override
	public List<Particle> ParticleList() {
		// TODO Auto-generated method stub
		return theParticles;
	}

	@Override
	public double get_g(){
		return this.g;
	}

	@Override
	public double[] get_G(int length) {
		double[] Grow=new double[length];
		Grow[p1.getIndex()*3]=Gp1x;
		Grow[p1.getIndex()*3+1]=Gp1y;
		Grow[p1.getIndex()*3+2]=Gp1z;
		return Grow;
	}
	@Override
	public double[] get_GDot(int length) {
		double[] Grow=new double[length];
		Grow[p1.getIndex()*3]=GdotP1x;
		Grow[p1.getIndex()*3+1]=GdotP1y;
		Grow[p1.getIndex()*3+2]=GdotP1z;
		return Grow;
	}


	
	/**The following methods should never be used for a pinned constraint but for now we just keep them here so that the constraint
	 * interface can extend the graph arc class.
	 * 
	 */
	@Override
	public Particle getHead() {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public Particle getTail() {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public Double getWeight() {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public void setWeight(WeightedInterface wi) {
		// TODO Auto-generated method stub	
	}
	@Override
	public WeightedInterface getWeightedInterface() {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public double setPoint() {
		// TODO Auto-generated method stub
		return 0;
	}
}
