import nokta3D;

class duzlem
{
protected double a,b,c;
//z=a+b*x+c*y;

  public duzlem(double a,double b,double c)
  {
  this.a=a;
  this.b=b;
  this.c=c;
  }

  public duzlem(nokta3D n0,nokta3D n1,nokta3D n2)
  {
  double y1,y2,y3,y4;
  y1=(n1.xkOku()-n0.xkOku())/(n1.xiOku()-n0.xiOku());
  y2=(n2.xkOku()-n0.xkOku())/(n2.xiOku()-n0.xiOku());
  y3=(n1.xjOku()-n0.xjOku())/(n1.xiOku()-n0.xiOku());
  y4=(n2.xjOku()-n0.xjOku())/(n2.xiOku()-n0.xiOku());
  c=(y1-y2)/(y3-y4);
  y1=(n1.xkOku()-n0.xkOku())/(n1.xjOku()-n0.xjOku());
  y2=(n2.xkOku()-n0.xkOku())/(n2.xjOku()-n0.xjOku());
  y3=(n1.xiOku()-n0.xiOku())/(n1.xjOku()-n0.xjOku());
  y4=(n2.xiOku()-n0.xiOku())/(n2.xjOku()-n0.xjOku());
  b=(y1-y2)/(y3-y4);
  a=n0.xkOku()-b*n0.xiOku()-c*n0.xjOku();
  }

  public duzlem(double xi0,double xj0,double xk0,
                double xi1,double xj1,double xk1,
                double xi2,double xj2,double xk2 )
  {
  double y1,y2,y3,y4;
  y1=(xk1-xk0)/(xi1-xi0);
  y2=(xk2-xk0)/(xi2-xi0);
  y3=(xj1-xj0)/(xi1-xi0);
  y4=(xj2-xj0)/(xi2-xi0);
  c=(y1-y2)/(y3-y4);
  y1=(xk1-xk0)/(xj1-xj0);
  y2=(xk2-xk0)/(xj2-xj0);
  y3=(xi1-xi0)/(xj1-xj0);
  y4=(xi2-xi0)/(xj2-xj0);
  b=(y1-y2)/(y3-y4);
  a=xk0-b*xi0-c*xj0;
  }

  public double aOku()
  {
  return a;
  }

  public double bOku()
  {
  return b;
  }

  public double cOku()
  {
  return c;
  }

  public double z(double xx, double yy)
  {
  return (a+b*xx+c*yy);
  }

  public double y(double xx, double zz)
  {
  return (zz-a-b*xx)/c;
  }

  public double x(double yy, double zz)
  {
  return (zz-a-c*yy)/b;
  }

  public String toString()
  {
  return "z = "+a+" + "+b+"x + "+c+"y";

  }

}
