// 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:   Momentum.java

package kinematics;


class Momentum
{

    Momentum(double d, double d1, double d2)
    {
        p = new double[3];
        p[0] = d;
        p[1] = d1;
        p[2] = d2;
    }

    Momentum()
    {
        p = new double[3];
        p[0] = p[1] = p[2] = 0.0D;
    }

    Momentum mult(double d)
    {
        return new Momentum(p[0] * d, p[1] * d, p[2] * d);
    }

    double skp(Momentum momentum)
    {
        return p[0] * momentum.p[0] + p[1] * momentum.p[1] + p[2] * momentum.p[2];
    }

    double abs()
    {
        return Math.sqrt(skp(this));
    }

    Momentum add(Momentum momentum)
    {
        return new Momentum(p[0] + momentum.p[0], p[1] + momentum.p[1], p[2] + momentum.p[2]);
    }

    Momentum sub(Momentum momentum)
    {
        return new Momentum(p[0] - momentum.p[0], p[1] - momentum.p[1], p[2] - momentum.p[2]);
    }

    double angle(Momentum momentum)
    {
        if(abs() <= 0.0D || momentum.abs() <= 0.0D)
            return 0.0D;
        else
            return (double)(p[1] * momentum.p[2] - p[2] * momentum.p[1] <= 0.0D ? -1 : 1) * Math.acos(skp(momentum) / abs() / momentum.abs());
    }

    double oopTh()
    {
        return Math.atan2(p[1], p[2]);
    }

    double oopPh()
    {
        return Math.atan2(p[0], Math.sqrt(p[1] * p[1] + p[2] * p[2]));
    }

    double p[];
}
