/** * Sets the value of this quaternion to (0, 0, 0, 1). Equivalent to calling set(0, 0, 0, 1) * * @return this quaternion for chaining */ public Quaternion setIdentity() { return set(0, 0, 0, 1); }
/** * Sets the value of this quaternion to (0, 0, 0, 1). Equivalent to calling set(0, 0, 0, 1) * * @return this quaternion for chaining */ public Quaternion setIdentity() { return set(0, 0, 0, 1); }
public void setRotation(final double x, final double y, final double z, final double w) { _rotation.set(x, y, z, w); }
public void setRotation(final double x, final double y, final double z, final double w) { _rotation.set(x, y, z, w); }
public void setRotation(final ReadOnlyQuaternion rotation) { _rotation.set(rotation); }
public void setRotation(final ReadOnlyQuaternion rotation) { _rotation.set(rotation); }
/** * Internally sets this quaternion to its conjugate <code>[-x, -y, -z, w]</code>. * * @return this <code>Quaternion</code> for chaining. */ public Quaternion conjugateLocal() { return set(-getX(), -getY(), -getZ(), getW()); }
/** * Internally sets this quaternion to its conjugate <code>[-x, -y, -z, w]</code>. * * @return this <code>Quaternion</code> for chaining. */ public Quaternion conjugateLocal() { return set(-getX(), -getY(), -getZ(), getW()); }
/** * @return this quaternion, modified to be unit length, for chaining. */ public Quaternion normalizeLocal() { final double n = 1.0 / magnitude(); final double x = getX() * n; final double y = getY() * n; final double z = getZ() * n; final double w = getW() * n; return set(x, y, z, w); }
/** * @return this quaternion, modified to be unit length, for chaining. */ public Quaternion normalizeLocal() { final double n = 1.0 / magnitude(); final double x = getX() * n; final double y = getY() * n; final double z = getZ() * n; final double w = getW() * n; return set(x, y, z, w); }
/** * Copy the source's values into this transform data object. * * @param source * our source to copy. * @throws NullPointerException * if source is null. */ public void set(final TransformData source) { _rotation.set(source.getRotation()); _scale.set(source.getScale()); _translation.set(source.getTranslation()); }
/** * Copy the source's values into this transform data object. * * @param source * our source to copy. * @throws NullPointerException * if source is null. */ public void set(final TransformData source) { _rotation.set(source.getRotation()); _scale.set(source.getScale()); _translation.set(source.getTranslation()); }
/** * Creates a new quaternion that is the conjugate <code>[-x, -y, -z, w]</code> of this quaternion. * * @param store * the <code>Quaternion</code> to store the result in. If <code>null</code>, a new one is created. * @return the conjugate to this quaternion. */ @Override public Quaternion conjugate(Quaternion store) { if (store == null) { store = new Quaternion(); } return store.set(-getX(), -getY(), -getZ(), getW()); }
/** * Creates a new quaternion that is the conjugate <code>[-x, -y, -z, w]</code> of this quaternion. * * @param store * the <code>Quaternion</code> to store the result in. If <code>null</code>, a new one is created. * @return the conjugate to this quaternion. */ @Override public Quaternion conjugate(Quaternion store) { if (store == null) { store = new Quaternion(); } return store.set(-getX(), -getY(), -getZ(), getW()); }
/** * @param quat * @param store * the Quaternion to store the result in. if null, a new one is created. * @return a quaternion representing the fields of this quaternion subtracted from those of the given quaternion. */ @Override public Quaternion subtract(final ReadOnlyQuaternion quat, final Quaternion store) { Quaternion result = store; if (result == null) { result = new Quaternion(); } return result.set(getX() - quat.getX(), getY() - quat.getY(), getZ() - quat.getZ(), getW() - quat.getW()); }
/** * @param quat * @param store * the Quaternion to store the result in. if null, a new one is created. * @return a quaternion representing the fields of this quaternion subtracted from those of the given quaternion. */ @Override public Quaternion subtract(final ReadOnlyQuaternion quat, final Quaternion store) { Quaternion result = store; if (result == null) { result = new Quaternion(); } return result.set(getX() - quat.getX(), getY() - quat.getY(), getZ() - quat.getZ(), getW() - quat.getW()); }
/** * Adds this quaternion to another and places the result in the given store. * * @param quat * @param store * the Quaternion to store the result in. if null, a new one is created. * @return a quaternion representing the fields of this quaternion added to those of the given quaternion. */ @Override public Quaternion add(final ReadOnlyQuaternion quat, final Quaternion store) { Quaternion result = store; if (result == null) { result = new Quaternion(); } return result.set(getX() + quat.getX(), getY() + quat.getY(), getZ() + quat.getZ(), getW() + quat.getW()); }
/** * Apply rotation around Y * * @param angle * in radians * @return this quaternion for chaining. */ public Quaternion applyRotationY(final double angle) { final double halfAngle = 0.5 * angle; final double sin = MathUtils.sin(halfAngle); final double cos = MathUtils.cos(halfAngle); final double newX = getX() * cos - getZ() * sin; final double newY = getY() * cos + getW() * sin; final double newZ = getX() * sin + getZ() * cos; final double newW = -getY() * sin + getW() * cos; return set(newX, newY, newZ, newW); }
/** * Multiplies this quaternion by the supplied quaternion values. The result is stored locally. * * @param qx * @param qy * @param qz * @param qw * @return this quaternion for chaining */ public Quaternion multiplyLocal(final double qx, final double qy, final double qz, final double qw) { final double x = getX() * qw + getY() * qz - getZ() * qy + getW() * qx; final double y = -getX() * qz + getY() * qw + getZ() * qx + getW() * qy; final double z = getX() * qy - getY() * qx + getZ() * qw + getW() * qz; final double w = -getX() * qx - getY() * qy - getZ() * qz + getW() * qw; return set(x, y, z, w); }
@Test public void testAddSubtract() { final Quaternion quat1 = new Quaternion(0, 1, 2, 3); final Quaternion quat2 = new Quaternion(1, 1, 1, 1); assertEquals(new Quaternion(1, 2, 3, 4), quat1.add(quat2, null)); assertEquals(new Quaternion(1, 2, 3, 4), quat1.add(quat2, new Quaternion())); assertEquals(new Quaternion(1, 2, 3, 4), quat1.addLocal(quat2)); quat1.set(0, 1, 2, 3); quat2.set(1, 1, 1, 1); assertEquals(new Quaternion(-1, 0, 1, 2), quat1.subtract(quat2, null)); assertEquals(new Quaternion(-1, 0, 1, 2), quat1.subtract(quat2, new Quaternion())); assertEquals(new Quaternion(-1, 0, 1, 2), quat1.subtractLocal(quat2)); }