/** * Divide a vector by a scalar and return the result in a new vector. * @param v the vector to divide by the scalar * @return a new vector that is v1 / n */ static public PVector div(PVector v, float n) { return div(v, n, null); }
/** * Divide a vector by a scalar and return the result in a new vector. * @param v the vector to divide by the scalar * @return a new vector that is v1 / n */ static public PVector div(PVector v, float n) { return div(v, n, null); }
/** * ( begin auto-generated from PVector_normalize.xml ) * * Normalize the vector to length 1 (make it a unit vector). * * ( end auto-generated ) * * @webref pvector:method * @usage web_application * @brief Normalize the vector to a length of 1 */ public void normalize() { float m = mag(); if (m != 0 && m != 1) { div(m); } }
/** * ( begin auto-generated from PVector_normalize.xml ) * * Normalize the vector to length 1 (make it a unit vector). * * ( end auto-generated ) * * @webref pvector:method * @usage web_application * @brief Normalize the vector to a length of 1 */ public PVector normalize() { float m = mag(); if (m != 0 && m != 1) { div(m); } return this; }
/** * Multiply a vector by a Matrix. * * @param mat source matrix * @param source vector to multiply * @param target output, will be created if null. * @return */ public static PVector mult(PMatrix3D mat, PVector source, PVector target) { if (target == null) { target = new PVector(); } target.x = mat.m00 * source.x + mat.m01 * source.y + mat.m02 * source.z + mat.m03; target.y = mat.m10 * source.x + mat.m11 * source.y + mat.m12 * source.z + mat.m13; target.z = mat.m20 * source.x + mat.m21 * source.y + mat.m22 * source.z + mat.m23; float tw = mat.m30 * source.x + mat.m31 * source.y + mat.m32 * source.z + mat.m33; if (tw != 0 && tw != 1) { target.div(tw); } return target; }