/*
  Loesung zur Aufgabe 2.05, H-Feld
*/
import java.awt.Color;
import java.lang.Math;

public class welle_2_05_H extends PlotAnimation
{
    public double welle(double x)
    {
	if( Math.abs(x) < 1.0 )
	    {
		double a=x+1.0;
		double b=1.0-x;
		return a*a*b*b*b;
	    }
	else
	    return 0.0;
    }

    public class Vorl extends Plot.PlotFunction
    {
	public Vorl(){color=Color.green;}
	public double fx(double p,double t) { return p_to_x(p); }
	public double fy(double p, double t)
	{
	    return welle(p_to_x(p)-t);
	}
    }
    public class Rueckl extends Plot.PlotFunction
    {
	public Rueckl(){color=Color.blue;}
	public double fx(double p,double t) { return p_to_x(p); }
	public double fy(double p,double t)
	{
	    return welle(20-p_to_x(p)-t);
	}
    }

    public class Ey_Feld extends Plot.PlotFunction
    {

	private double x_true(double p)
	{
	    return 10.0+(get_x_min()-10.0)*p;
	}

	public double fx(double p, double t)
	{
	    return x_true(p);
	}

	public double fy(double p,double t)
	{
	    return welle(x_true(p)-t)+welle(20-x_true(p)-t);
	}
    }


    // Konstruktor:
    public welle_2_05_H()
    {

	set_p_range(0.0,1.0,0.01);
	set_x_range(7.7,12.3);
	set_y_range(-2.6,2.6);
	set_x_tics(8.0,1.0);
	set_y_tics(-2.5,0.5);
	set_t_range(7.0,13.0,0.07);
	graphs.addElement(new Vorl());
	graphs.addElement(new Rueckl());
	graphs.addElement(new Ey_Feld());
	// Grenzschicht:
	lines.addElement(new Line(10.0,-2.6,10.0,2.6));
    }
}



