/** * Calculate the conjugate of this quaternion */ public Vector negate() { return negate(this, this); }
/** * Normalise this quaternion and place the result in another quaternion. * * @param dest * The destination quaternion, or null if a new quaternion is to be * created * @return the normalised quaternion */ public Quaternion normalise(Quaternion dest) { return normalise(this, dest); }
/** * C'tor * * @param src */ public Quaternion(ReadableVector4f src) { set(src); }
/** * Normalise the source quaternion and place the result in another quaternion. * * @param src * The source quaternion * @param dest * The destination quaternion, or null if a new quaternion is to be * created * @return The normalised quaternion */ public static Quaternion normalise(Quaternion src, Quaternion dest) { float inv_l = 1f/src.length(); if (dest == null) dest = new Quaternion(); dest.set(src.x * inv_l, src.y * inv_l, src.z * inv_l, src.w * inv_l); return dest; }
float n = right.lengthSquared(); dest = new Quaternion(); dest .set((left.x * right.w - left.w * right.x - left.y
/** * Sets the value of this quaternion to the quaternion product of * quaternions left and right (this = left * right). Note that this is safe * for aliasing (e.g. this can be left or right). * * @param left * the first quaternion * @param right * the second quaternion */ public static Quaternion mul(Quaternion left, Quaternion right, Quaternion dest) { if (dest == null) dest = new Quaternion(); dest.set(left.x * right.w + left.w * right.x + left.y * right.z - left.z * right.y, left.y * right.w + left.w * right.y + left.z * right.x - left.x * right.z, left.z * right.w + left.w * right.z + left.x * right.y - left.y * right.x, left.w * right.w - left.x * right.x - left.y * right.y - left.z * right.z); return dest; }
/** * Sets the value of this quaternion using the rotational component of the * passed matrix. * * @param m * The source matrix */ public final Quaternion setFromMatrix(Matrix3f m) { return setFromMatrix(m, this); }
/** * C'tor. The quaternion will be initialized to the identity. */ public Quaternion() { super(); setIdentity(); }
/** * Sets the value of the source quaternion using the rotational component of the * passed matrix. * * @param m * The source matrix * @param q * The destination quaternion, or null if a new quaternion is to be created * @return q */ public static Quaternion setFromMatrix(Matrix3f m, Quaternion q) { return q.setFromMat(m.m00, m.m01, m.m02, m.m10, m.m11, m.m12, m.m20, m.m21, m.m22); }
/** * Scale the source quaternion by scale and put the result in the destination * @param scale The amount to scale by * @param src The source quaternion * @param dest The destination quaternion, or null if a new quaternion is to be created * @return The scaled quaternion */ public static Quaternion scale(float scale, Quaternion src, Quaternion dest) { if (dest == null) dest = new Quaternion(); dest.x = src.x * scale; dest.y = src.y * scale; dest.z = src.z * scale; dest.w = src.w * scale; return dest; }
public Vector scale(float scale) { return scale(scale, this, this); }
/** * Sets the value of this quaternion using the rotational component of the * passed matrix. * * @param m * The matrix * @return this */ public final Quaternion setFromMatrix(Matrix4f m) { return setFromMatrix(m, this); }
/** * Set this quaternion to the multiplication identity. * @return this */ public Quaternion setIdentity() { return setIdentity(this); }
/** * Sets the value of the source quaternion using the rotational component of the * passed matrix. * * @param m * The source matrix * @param q * The destination quaternion, or null if a new quaternion is to be created * @return q */ public static Quaternion setFromMatrix(Matrix4f m, Quaternion q) { return q.setFromMat(m.m00, m.m01, m.m02, m.m10, m.m11, m.m12, m.m20, m.m21, m.m22); }
/** * Calculate the conjugate of this quaternion and put it into the given one * * @param src * The source quaternion * @param dest * The quaternion which should be set to the conjugate of this * quaternion */ public static Quaternion negate(Quaternion src, Quaternion dest) { if (dest == null) dest = new Quaternion(); dest.x = -src.x; dest.y = -src.y; dest.z = -src.z; dest.w = src.w; return dest; }
/** * C'tor * */ public Quaternion(float x, float y, float z, float w) { set(x, y, z, w); }
/** * Calculate the conjugate of this quaternion and put it into the given one * * @param dest * The quaternion which should be set to the conjugate of this * quaternion */ public Quaternion negate(Quaternion dest) { return negate(this, dest); }