import sk.uniba.fmph.pocprak.simplegraphics.GrGraphics;
/**
 * reprezentuje tienidlo
 */
public class Tienidlo
    implements OpticalSurface {
  /**
   * poloha roviny tienidla na optickej osi
   */
  double x;
    
  public Tienidlo(double x){
    this.x = x;
  }
  public boolean movesTowards(Beam b) {
    if (b.dir.x == 0) {
      return true;  //luc sa uz nesiri, formalne posleme true aby sme sa vyhli
                    //zbytocnemu volaniu SurfaceEffect 
    }
    if ( (b.p.x - x) * b.dir.x < 0) {
      return true;
    }
    return false;
  }

  public void SurfaceEffect(Beam b) {
    b.dir.x=0;
    b.dir.y=0;
  }

  public void draw(GrGraphics gr, Tubus t) {
    if (x>t.xin && x<t.xout) gr.drawLine2D(x,-t.r,x,t.r);
    else gr.drawLine2D(x,-100.,x,100.);
  }
}
