package clothSimulator;

//this is a pinning constraint that constrains the value of the y coordinate of a particle

public class YPinnedConstraint extends PinnedConstraint {

	//the desired location of the y coord of the pinned particle
	double yPinPos;

	
	public YPinnedConstraint(Particle p, double pos) {
		super(p, pos);
		// TODO Auto-generated constructor stub
		this.p1=p;
		this.yPinPos=pos;
		this.ParticleList().add(p1);
	}

	@Override
	public void updateCurrent_g() {
		// TODO Auto-generated method stub
		g= this.p1.p.y-yPinPos;
	}
	
	@Override
	public void updateCurrent_G(){
		Gp1x=0;
		Gp1y=1;
		Gp1z=0;
	}
	
	@Override
	public double GiDot(double[] in) {
		return in[this.p1.getIndex()*3+1];
	}
	
	@Override
	public void GtransiDot(double[] in, double[] out){
		out[this.p1.getIndex()*3+1]+=this.Gp1y*in[this.getCLIndex()];
		
	}
	
}
