// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   Fourvector.java

package kinematics;

import java.awt.Color;
import java.awt.Graphics;
import java.io.PrintStream;

// Referenced classes of package kinematics:
//            Momentum

class Fourvector
{

    Fourvector(double d, Momentum momentum)
    {
        p = momentum;
        E = d;
    }

    Fourvector(double d, double d1, double d2, double d3)
    {
        p = new Momentum(d1, d2, d3);
        E = d;
    }

    Fourvector add(Fourvector fourvector)
    {
        return new Fourvector(E + fourvector.E, p.add(fourvector.p));
    }

    Fourvector sub(Fourvector fourvector)
    {
        return new Fourvector(E - fourvector.E, p.sub(fourvector.p));
    }

    double mult(Fourvector fourvector)
    {
        return E * fourvector.E - p.skp(fourvector.p);
    }

    double masssquare()
    {
        return mult(this);
    }

    double mass()
    {
        return Math.sqrt(masssquare());
    }

    double angle()
    {
        return p.angle(new Momentum(0.0D, 0.0D, 1.0D));
    }

    double angle(Fourvector fourvector)
    {
        return p.angle(fourvector.p);
    }

    Fourvector rotatetheta(double d)
    {
        return new Fourvector(E, new Momentum(p.p[0], p.p[1] * Math.cos(d) + p.p[2] * Math.sin(d), p.p[2] * Math.cos(d) - p.p[1] * Math.sin(d)));
    }

    Fourvector Lorentz(Fourvector fourvector)
    {
        if(fourvector.p.abs() <= 0.0D)
            return this;
        Momentum momentum = fourvector.p.mult(1.0D / fourvector.E);
        double d = momentum.abs();
        if(d >= 1.0D)
        {
            return fourvector;
        } else
        {
            double d1 = 1.0D / Math.sqrt(1.0D - d * d);
            return new Fourvector(d1 * (E + p.skp(momentum)), p.add(momentum.mult(d1 * ((d1 / (1.0D + d1)) * p.skp(momentum) + E))));
        }
    }

    void draw(Graphics g, Fourvector fourvector, double d, String s)
    {
        if(p.abs() >= 0.0D && d >= 0.0D)
        {
            double d1 = p.abs() * d;
            int i = (int)(d * fourvector.p.p[1]);
            int j = -(int)(d * fourvector.p.p[2]);
            int k = i + (int)(d * p.p[1]);
            int l = j - (int)(d * p.p[2]);
            int i1 = (int)(((double)((-k + i + l / 2) - j / 2) / d1) * 7D);
            int j1 = (int)(((double)(((-k / 2 + i / 2) - l) + j) / d1) * 7D);
            int k1 = (int)(((double)(((-k + i) - l / 2) + j / 2) / d1) * 7D);
            int l1 = (int)(((double)((k / 2 - i / 2 - l) + j) / d1) * 7D);
            g.drawLine(i, j, k, l);
            g.drawLine(k, l, k + k1, l + l1);
            g.drawLine(k, l, k + i1, l + j1);
            g.setColor(Color.black);
            g.drawString(s, k, l);
        }
    }

    void print(Fourvector fourvector, double d, String s)
    {
        double d1 = p.abs() * d;
        double d2 = (fourvector.p.abs() * d * fourvector.p.p[1]) / fourvector.p.abs();
        double d3 = (-fourvector.p.abs() * d * fourvector.p.p[2]) / fourvector.p.abs();
        double d4 = d2 + (d1 * p.p[1]) / p.abs();
        double d5 = d3 - (d1 * p.p[2]) / p.abs();
        double d6 = d4 + (((-d4 + d2 + d5 / 2D) - d3 / 2D) / d1) * 0.20000000000000001D;
        double d7 = d5 + ((((-d4 / 2D + d2 / 2D) - d5) + d3) / d1) * 0.20000000000000001D;
        double d8 = d4 + ((((-d4 + d2) - d5 / 2D) + d3 / 2D) / d1) * 0.20000000000000001D;
        double d9 = d5 + (((d4 / 2D - d2 / 2D - d5) + d3) / d1) * 0.20000000000000001D;
        System.out.println((new StringBuilder()).append("n ").append(d2).append(" ").append(-d3).append(" m ").append(d4).append(" ").append(-d5).append(" l s").toString());
        System.out.println((new StringBuilder()).append("n ").append(d4).append(" ").append(-d5).append(" m ").append(d6).append(" ").append(-d7).append(" l ").toString());
        System.out.println((new StringBuilder()).append("").append(d8).append(" ").append(-d9).append(" l closepath fill ").toString());
        System.out.println((new StringBuilder()).append("0 setgray n ").append(d4).append(" ").append(-d5).append(" m (").append(s).append(") show").toString());
    }

    double E;
    Momentum p;
}
