/*KoordTrafo.java*/
public class KoordTrafo{
    double[] ursprung = new double[2];
    double[] x = new double[2];

    KoordTrafo(double ursprung0,double ursprung1,double x0,double x1){
	ursprung[0]=ursprung0;
	ursprung[1]=ursprung1;
	x[0]=x0;
	x[1]=x1;
    }
    
    double betrag(double[] u){
	return Math.sqrt(u[0]*u[0]+u[1]*u[1]);
    }

    double[] trafo(double p0,double p1){
	double[] neu = new double[2];
	double quadrat=x[0]*x[0]+x[1]*x[1];
	neu[0]=x[0]/quadrat*(p0-ursprung[0])+x[1]/quadrat*(p1-ursprung[1]);
	neu[1]=-x[1]/quadrat*(p0-ursprung[0])+x[0]/quadrat*(p1-ursprung[1]);
	return neu;
    }

    double[] ofart(double p0,double p1){
	double[] neu = new double[2];
	double betrag = Math.sqrt(x[0]*x[0]+x[1]*x[1]);
	neu[0]=1/betrag*(x[0]*p0-x[1]*p1)+ursprung[0];
	neu[1]=1/betrag*(x[1]*p0+x[0]*p1)+ursprung[1];
	return neu;
    }
}
