/*
 * Parabolabola.java
 *
 * Created on 11 styczeń 2004, 15:00
 */

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 HorizontalParabola extends PolarChartConstraints{
    
    /** Creates a new instance of Parabola */
    public HorizontalParabola(double p, AbstractDoubleVector cent)
    {
      super(cent);
      double c;
      points = new AbstractDoubleVector[1];
      points[0]=cent;
     /*if (a>b) {
          c=Math.sqrt(a*a-b*b);
          center=cent.add(new Double2Vector(c,0));
      } else{
          c=Math.sqrt(-a*a+b*b);
            center=cent.add(new Double2Vector(0,c));
      }*/
      params=new double[1];
      params[0]=p;
     }
    public void draw(ClassicalParticleV2D p, java.awt.Graphics2D g2D) {
     /* if (draw){
       double x0=points[0].getComponent(0)-params[0];
       double y0=points[0].getComponent(1)-params[1];
       g2D.setColor(Color.black);
       g2D.drawOval((int)x0,(int)y0,(int)(2*params[0]),(int)(2*params[1]));
      }*/
    }
    public void erase(ClassicalParticleV2D p, java.awt.Graphics2D g2D) {
      /*if (draw){ 
       double x0=points[0].getComponent(0)-params[0];
       double y0=points[0].getComponent(1)-params[1];
       g2D.setColor(Color.white);
       g2D.drawOval((int)x0,(int)y0,(int)(2*params[0]),(int)(2*params[1]));
      }*/
    }
    public AbstractDoubleVector getTangent(AbstractDoubleVector x0) {
        AbstractDoubleVector r1=x0.subtract(center);
        AbstractDoubleVector tan=new Double2Vector(
                                 2.*r1.getComponent(1),-2.*params[0]);
        tan.normalize();
        return tan;
    }
    
   protected double getRadius(double ang) {
     return  params[0]/(1+Math.sin(ang));
   }
 
}
