package org.avmdti.josast.util;

/**
 * Utility class for Vector.  This vector is a four dimensional vector
 * used for rectangular coordinate This vector contains :  3-dimensional
 * vector,  the fourth element contains the magnitude.
 *
 * @author Xtophe
 * @version 1.0
 */
public class VectorFourDim {
    //~ Static fields/initializers ----------------------------------------

    /*
     */

    /** X dimension. */
    public static final int X = 0;

    /** Y dimension. */
    public static final int Y = 1;

    /** Z dimension. */
    public static final int Z = 2;

    /** magnitude. */
    public static final int M = 3;

    //~ Instance fields ---------------------------------------------------

    /** array for the vector.   TODO : set to private */
    public double v[] = new double[4];

    //~ Constructors ------------------------------------------------------

    /**
     * Creates a new VectorFourDim object.
     *
     * @param x2 X value
     * @param y2 Y value
     * @param z2 z value
     * @param w magnitude
     */
    public VectorFourDim(double x2, double y2, double z2, double w) {
        v[X] = x2;
        v[Y] = y2;
        v[Z] = z2;
        v[M] = w;
    }

    /**
     * Creates a new VectorFourDim object.     Magnitude is set to 0.
     *
     * @param d X value
     * @param e Y value
     * @param f Z value
     */
    public VectorFourDim(double d, double e, double f) {
        v[X] = d;
        v[Y] = e;
        v[Z] = f;
        v[M] = 0;
    }

    /**
     * Creates a new VectorFourDim object. All value is set to 0.
     */
    public VectorFourDim() {
        v[X] = 0;
        v[Y] = 0;
        v[Z] = 0;
        v[M] = 0;
    }

    //~ Methods -----------------------------------------------------------

    /**
     * multiply the vector by a value.
     *
     * @param factor factor for the multiplication
     */
    public void mul(final double factor) {
        v[X] *= factor;
        v[Y] *= factor;
        v[Z] *= factor;
        v[M] *= Math.abs(factor);
    }
}
