/** * Constructor */ public Vector4f(ReadableVector4f src) { set(src); }
/** * Constructor */ public Vector4f(float x, float y, float z, float w) { set(x, y, z, w); }
/** * Add a vector to another vector and place the result in a destination * vector. * @param left The LHS vector * @param right The RHS vector * @param dest The destination vector, or null if a new vector is to be created * @return the sum of left and right in dest */ public static Vector4f add(Vector4f left, Vector4f right, Vector4f dest) { if (dest == null) return new Vector4f(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); else { dest.set(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); return dest; } }
/** * Subtract a vector from another vector and place the result in a destination * vector. * @param left The LHS vector * @param right The RHS vector * @param dest The destination vector, or null if a new vector is to be created * @return left minus right in dest */ public static Vector4f sub(Vector4f left, Vector4f right, Vector4f dest) { if (dest == null) return new Vector4f(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); else { dest.set(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); return dest; } }
/** * Normalise this vector and place the result in another vector. * @param dest The destination vector, or null if a new vector is to be created * @return the normalised vector */ public Vector4f normalise(Vector4f dest) { float l = length(); if (dest == null) dest = new Vector4f(x / l, y / l, z / l, w / l); else dest.set(x / l, y / l, z / l, w / l); return dest; }