/*
 * HorizontalLine.java
 *
 * Created on 22 grudzień 2004, 00:20
 */

package JSciDraw.physics.forces.constraints;

import JSci.maths.*;
import JSci.physics.*;
import JSciDraw.*;
import JSciDraw.physics.*;
import JSciDraw.physics.forces.*;
import java.awt.*;

/**
 *
 * @author  Barbara 
 */
public class HorizontalLine extends Constraints{
    
    /** Creates a new instance of HorizontalLine */
    public HorizontalLine() {
    }
    
    public void draw(ClassicalParticleV2D p, java.awt.Graphics2D g2D) {
      if (draw){
       g2D.setColor(Color.black);
       g2D.drawLine(0, (int)p.getPosition().getComponent(1),800, (int)p.getPosition().getComponent(1));
      }
    }
    public void erase(ClassicalParticleV2D p, java.awt.Graphics2D g2D) {
     if (draw){
      g2D.setColor(Color.black);
      g2D.drawLine(0, (int)p.yOl,800, (int)p.yOl);
     }
    }
    
    public void move(ClassicalParticleV2D p, AbstractDoubleVector force, double dt)
    {
     AbstractDoubleVector fc;
     fc=getTangent(new Double2Vector()).scalarMultiply(force.scalarProduct(getTangent(new Double2Vector())));
     fc=fc.scalarMultiply(dt/(p.getMass()));
     p.setVelocity((p.getVelocity()).add(fc));
     p.setPosition(p.getPosition().add((p.getVelocity()).scalarMultiply(dt)));
    }

    public AbstractDoubleVector getTangent(AbstractDoubleVector x0) {
        return new Double2Vector(1,0);
    }
    
    public AbstractDoubleVector toEuclidean(AbstractDoubleVector generic) {
        return generic;
    }
    
    public AbstractDoubleVector toGeneric(AbstractDoubleVector euclidean) {
        return euclidean;
    }
    
    public void setPosition(AbstractDoubleVector x) {
    }
    
    public AbstractDoubleVector getPosition() {
        return new Double2Vector(0,0);
    }
    
}
