/*
 * Author: Paul Koshevoy
 * Parameters.java  Tue, Feb 3 1998, 23:00:00 1998
 */

//----------------------------------------------------------------
// Parameters
// 
public class Parameters
{
  public double PI; // 3.1415... constant
  
  public double H2; // height of second mirror
  public double HT; // height of the screen
  public double WD; // width of the screen
  public double D1; // distance d1
  public double S1; // distance S1
  public double S2; // distance S2
  public double G1; // angle gamma1
  public double G2; // angle gamma2
  public double P1; // angle phi1
  public double P2; // angle phi2
  public double T1; // angle theta1
  public double B1; // beta one angle
  public double I;  // Z-component of upper corner screen coordinates
  public double J;  // Y-component of upper corner screen coordinates
  public double K;  // Z-component of lower corner screen coordinates
  public double L;  // Y-component of lower corner screen coordinates
  public double dP; // delta phi
  public double dG; // delta gamma
  public double C;  // depth of the screen
  public double Cy; // projection of C on axis Y
  public double RHO;// angle rho
    
  public double PIo2;// Pi over 2
  
  public Parameters(double d1,
		    double s2,
		    double gamma1,
		    double ht,
		    double a,
		    double b)
  {
    // d1:
    // distance between laser emmiter and first reflection point
    
    // s2:
    // distance between first reflection point and second reflection point
    
    // gamma1:
    // arbitrary mimimal angle at which laser may hit second mirror,
    // NOTE: gamma1 > 0
    
    // ht:
    // height of the screen
    
    // a:
    // a-component of a/b ratio between height and width of the screen
    
    // b:
    // b-component of a/b ratio between height and width of the screen
    
    PI = 4 * Math.atan(1);
    PIo2 = PI/2;
    D1 = d1;
    S2 = s2;
    G1 = gamma1;
    HT = ht;
    WD = (b * HT) / a;
    B1 = Math.atan2(D1, S2) / 2;
    T1 = PI - G1 - G1 - B1 - B1;
    S1 = HT / (2 * Math.sin(T1 / 2));
    G2 = Math.PI/2 - B1;
    C = HT / (2 * Math.tan(T1 / 2));
    RHO = PIo2 - T1 / 2 - G1;
    Cy  = C * Math.tan(RHO);
    H2  = (S2 * WD) / (S2 + Cy);
    
    P2 = Math.atan2(S2, H2 / 2);
    P1 = Math.PI - P2;
    I  = S1 * Math.sin(2 * G1);
    J  = S1 * Math.cos(2 * G1);
    K  = S1 * Math.sin(2 * B1);
    L  = S1 * Math.cos(2 * B1);
    dP = P1 - P2;
    dG = G2 - G1;
    System.out.println(H2);
  }
  
  //----------------------------------------------------------------
  // get_x
  // 
  public double get_x(double alpha1, double alpha2, int sx)
  {
    double A4 = 2 * G1 - 2 * alpha2 + T1 / 2;
    double D = C / (Math.cos(A4));
    double X = (D + S2) / Math.tan(alpha1);
    return (WD / 2 - X);
  }
  
  //----------------------------------------------------------------
  // get_y
  // 
  public double get_y(double alpha2, int sy)
  {
    double A4 = 2 * G1 - 2 * alpha2 + T1 / 2;
    double Y  = C * Math.tan(A4);
    return (HT / 2 - Y);
  }
}

