us.ihmc.euclid.referenceFrame.interfaces.FixedFrameQuaternionBasics Maven / Gradle / Ivy
package us.ihmc.euclid.referenceFrame.interfaces;
import us.ihmc.euclid.referenceFrame.ReferenceFrame;
import us.ihmc.euclid.referenceFrame.exceptions.ReferenceFrameMismatchException;
import us.ihmc.euclid.tuple4D.interfaces.QuaternionBasics;
import us.ihmc.euclid.tuple4D.interfaces.QuaternionReadOnly;
/**
* Write and read interface for a quaternion expressed in a constant reference frame, i.e. the
* reference frame of this object cannot be changed via this interface.
*
* In addition to representing a {@link QuaternionBasics}, a {@link ReferenceFrame} is associated to
* a {@code FixedFrameQuaternionBasics}. This allows, for instance, to enforce, at runtime, that
* operations on quaternions occur in the same coordinate system. Also, via the method
* {@link FrameChangeable#changeFrame(ReferenceFrame)}, one can easily calculates the value of a
* quaternion in different reference frames.
*
*
* Because a {@code FixedFrameQuaternionBasics} extends {@code QuaternionBasics}, it is compatible
* with methods only requiring {@code QuaternionBasics}. However, these methods do NOT assert that
* the operation occur in the proper coordinate system. Use this feature carefully and always prefer
* using methods requiring {@code FixedFrameQuaternionBasics}.
*
*/
public interface FixedFrameQuaternionBasics extends FrameQuaternionReadOnly, FixedFrameTuple4DBasics, FixedFrameOrientation3DBasics, QuaternionBasics
{
/**
* Sets this frame quaternion to {@code quaternionReadOnly} and checks that its current frame equals
* {@code referenceFrame}.
*
* @param referenceFrame the coordinate system in which the given {@code quaternionReadOnly} is
* expressed.
* @param quaternionReadOnly the quaternion to copy the values from. Not modified.
* @throws ReferenceFrameMismatchException if {@code this.referenceFrame != referenceFrame}.
*/
default void set(ReferenceFrame referenceFrame, QuaternionReadOnly quaternionReadOnly)
{
checkReferenceFrameMatch(referenceFrame);
set(quaternionReadOnly);
}
/**
* Sets this frame quaternion to {@code other}.
*
* @param other the other quaternion to copy the values from. Not modified.
* @throws ReferenceFrameMismatchException if {@code other} is not expressed in the same reference
* frame as {@code this}.
*/
default void set(FrameQuaternionReadOnly other)
{
checkReferenceFrameMatch(other);
QuaternionBasics.super.set(other);
}
/**
* Sets this frame quaternion to {@code other}.
*
* If {@code other} is expressed in the frame as {@code this}, then this method is equivalent to
* {@link #set(FrameQuaternionReadOnly)}.
*
*
* If {@code other} is expressed in a different frame than {@code this}, then {@code this} is set to
* {@code other} and then transformed to be expressed in {@code this.getReferenceFrame()}.
*
*
* @param other the other quaternion to copy the values from. Not modified.
*/
default void setMatchingFrame(FrameQuaternionReadOnly other)
{
QuaternionBasics.super.set(other);
other.getReferenceFrame().transformFromThisToDesiredFrame(getReferenceFrame(), this);
}
/**
* Sets this frame quaternion to {@code other} and then calls {@link #negate()}.
*
* @param other the other frame quaternion to set to. Not modified.
* @throws ReferenceFrameMismatchException if {@code other} is not expressed in the same reference
* frame as {@code this}.
*/
default void setAndNegate(FrameQuaternionReadOnly other)
{
checkReferenceFrameMatch(other);
QuaternionBasics.super.setAndNegate(other);
}
/**
* Sets this frame quaternion to the conjugate of {@code other}.
*
*
* / -qx \
* q* = | -qy |
* | -qz |
* \ qs /
*
*
* @param other the other frame quaternion to copy the values from. Not modified.
* @throws ReferenceFrameMismatchException if {@code other} is not expressed in the same reference
* frame as {@code this}.
*/
default void setAndConjugate(FrameQuaternionReadOnly other)
{
checkReferenceFrameMatch(other);
QuaternionBasics.super.setAndConjugate(other);
}
/**
* Sets this frame quaternion to {@code other} and then calls {@link #normalize()}.
*
* @param other the other frame quaternion to copy the values from. Not modified.
* @throws ReferenceFrameMismatchException if {@code other} is not expressed in the same reference
* frame as {@code this}.
*/
default void setAndNormalize(FrameQuaternionReadOnly other)
{
checkReferenceFrameMatch(other);
QuaternionBasics.super.setAndNormalize(other);
}
/**
* Performs a linear interpolation in SO(3) from {@code this} to {@code qf} given the percentage
* {@code alpha}.
*
* The interpolation method used here is often called a Spherical Linear Interpolation or
* SLERP.
*
*
* @param qf the other frame quaternion used for the interpolation. Not modified.
* @param alpha the percentage used for the interpolation. A value of 0 will result in not modifying
* this frame quaternion, while a value of 1 is equivalent to setting this frame
* quaternion to {@code qf}.
* @throws ReferenceFrameMismatchException if {@code qf} is not expressed in the same reference
* frame as {@code this}.
*/
default void interpolate(FrameQuaternionReadOnly qf, double alpha)
{
checkReferenceFrameMatch(qf);
QuaternionBasics.super.interpolate(qf, alpha);
}
/**
* Performs a linear interpolation in SO(3) from {@code q0} to {@code qf} given the percentage
* {@code alpha}.
*
* The interpolation method used here is often called a Spherical Linear Interpolation or
* SLERP.
*
*
* @param q0 the first frame quaternion used in the interpolation. Not modified.
* @param qf the second quaternion used in the interpolation. Not modified.
* @param alpha the percentage to use for the interpolation. A value of 0 will result in setting
* this frame quaternion to {@code q0}, while a value of 1 is equivalent to setting
* this frame quaternion to {@code qf}.
* @throws ReferenceFrameMismatchException if {@code q0} is not expressed in the same reference
* frame as {@code this}.
*/
default void interpolate(FrameQuaternionReadOnly q0, QuaternionReadOnly qf, double alpha)
{
checkReferenceFrameMatch(q0);
QuaternionBasics.super.interpolate(q0, qf, alpha);
}
/**
* Performs a linear interpolation in SO(3) from {@code q0} to {@code qf} given the percentage
* {@code alpha}.
*
* The interpolation method used here is often called a Spherical Linear Interpolation or
* SLERP.
*
*
* @param q0 the first quaternion used in the interpolation. Not modified.
* @param qf the second frame quaternion used in the interpolation. Not modified.
* @param alpha the percentage to use for the interpolation. A value of 0 will result in setting
* this frame quaternion to {@code q0}, while a value of 1 is equivalent to setting
* this frame quaternion to {@code qf}.
* @throws ReferenceFrameMismatchException if {@code qf} is not expressed in the same reference
* frame as {@code this}.
*/
default void interpolate(QuaternionReadOnly q0, FrameQuaternionReadOnly qf, double alpha)
{
checkReferenceFrameMatch(qf);
QuaternionBasics.super.interpolate(q0, qf, alpha);
}
/**
* Performs a linear interpolation in SO(3) from {@code q0} to {@code qf} given the percentage
* {@code alpha}.
*
* The interpolation method used here is often called a Spherical Linear Interpolation or
* SLERP.
*
*
* @param q0 the first quaternion used in the interpolation. Not modified.
* @param qf the second quaternion used in the interpolation. Not modified.
* @param alpha the percentage to use for the interpolation. A value of 0 will result in setting
* this quaternion to {@code q0}, while a value of 1 is equivalent to setting this
* quaternion to {@code qf}.
* @throws ReferenceFrameMismatchException if either {@code q0} or {@code qf} is not expressed in
* the same frame as {@code this}.
*/
default void interpolate(FrameQuaternionReadOnly q0, FrameQuaternionReadOnly qf, double alpha)
{
checkReferenceFrameMatch(q0, qf);
QuaternionBasics.super.interpolate(q0, qf, alpha);
}
/**
* Multiplies this frame quaternion by {@code other}.
*
* this = this * other
*
*
* @param other the other frame quaternion to multiply this. Not modified.
* @throws ReferenceFrameMismatchException if {@code other} is not expressed in the same reference
* frame as {@code this}.
*/
default void multiply(FrameQuaternionReadOnly other)
{
checkReferenceFrameMatch(other);
QuaternionBasics.super.multiply(other);
}
/**
* Sets this frame quaternion to the multiplication of {@code q1} and {@code q2}.
*
* this = q1 * q2
*
*
* @param q1 the first frame quaternion in the multiplication. Not modified.
* @param q2 the second quaternion in the multiplication. Not modified.
* @throws ReferenceFrameMismatchException if {@code q1} is not expressed in the same reference
* frame as {@code this}.
*/
default void multiply(FrameQuaternionReadOnly q1, QuaternionReadOnly q2)
{
checkReferenceFrameMatch(q1);
QuaternionBasics.super.multiply(q1, q2);
}
/**
* Sets this frame quaternion to the multiplication of {@code q1} and {@code q2}.
*
* this = q1 * q2
*
*
* @param q1 the first quaternion in the multiplication. Not modified.
* @param q2 the second frame quaternion in the multiplication. Not modified.
* @throws ReferenceFrameMismatchException if {@code q2} is not expressed in the same reference
* frame as {@code this}.
*/
default void multiply(QuaternionReadOnly q1, FrameQuaternionReadOnly q2)
{
checkReferenceFrameMatch(q2);
QuaternionBasics.super.multiply(q1, q2);
}
/**
* Sets this frame quaternion to the multiplication of {@code q1} and {@code q2}.
*
* this = q1 * q2
*
*
* @param q1 the first frame quaternion in the multiplication. Not modified.
* @param q2 the second frame quaternion in the multiplication. Not modified.
* @throws ReferenceFrameMismatchException if either {@code q1} or {@code q2} is not expressed in
* the same frame as {@code this}.
*/
default void multiply(FrameQuaternionReadOnly q1, FrameQuaternionReadOnly q2)
{
checkReferenceFrameMatch(q1, q2);
QuaternionBasics.super.multiply(q1, q2);
}
/**
* Sets this frame quaternion to the difference of {@code q1} and {@code q2}.
*
* this = q1-1 * q2
*
*
* @param q1 the first frame quaternion in the difference. Not modified.
* @param q2 the second quaternion in the difference. Not modified.
* @throws ReferenceFrameMismatchException if {@code q1} is not expressed in the same reference
* frame as {@code this}.
*/
default void difference(FrameQuaternionReadOnly q1, QuaternionReadOnly q2)
{
checkReferenceFrameMatch(q1);
QuaternionBasics.super.difference(q1, q2);
}
/**
* Sets this quaternion to the difference of {@code q1} and {@code q2}.
*
* this = q1-1 * q2
*
*
* @param q1 the first quaternion in the difference. Not modified.
* @param q2 the second frame quaternion in the difference. Not modified.
* @throws ReferenceFrameMismatchException if {@code q2} is not expressed in the same reference
* frame as {@code this}.
*/
default void difference(QuaternionReadOnly q1, FrameQuaternionReadOnly q2)
{
checkReferenceFrameMatch(q2);
QuaternionBasics.super.difference(q1, q2);
}
/**
* Sets this quaternion to the difference of {@code q1} and {@code q2}.
*
* this = q1-1 * q2
*
*
* @param q1 the first frame quaternion in the difference. Not modified.
* @param q2 the second frame quaternion in the difference. Not modified.
* @throws ReferenceFrameMismatchException if either {@code q1} or {@code q2} is not expressed in
* the same frame as {@code this}.
*/
default void difference(FrameQuaternionReadOnly q1, FrameQuaternionReadOnly q2)
{
checkReferenceFrameMatch(q1, q2);
QuaternionBasics.super.difference(q1, q2);
}
/**
* Multiplies this frame quaternion by the conjugate of {@code other}.
*
* this = this * other*
*
*
* @param other the other frame quaternion to multiply this with. Not modified.
* @throws ReferenceFrameMismatchException if {@code other} is not expressed in the same reference
* frame as {@code this}.
*/
default void multiplyConjugateOther(FrameQuaternionReadOnly other)
{
checkReferenceFrameMatch(other);
QuaternionBasics.super.multiplyConjugateOther(other);
}
/**
* Sets this frame quaternion to the multiplication of the conjugate of {@code this} and
* {@code other}.
*
* this = this* * other
*
*
* @param other the other frame quaternion to multiply this with. Not modified.
* @throws ReferenceFrameMismatchException if {@code other} is not expressed in the same reference
* frame as {@code this}.
*/
default void multiplyConjugateThis(FrameQuaternionReadOnly other)
{
checkReferenceFrameMatch(other);
QuaternionBasics.super.multiplyConjugateThis(other);
}
/**
* Sets this frame quaternion to the multiplication of the conjugate of {@code this} and the
* conjugate of {@code other}.
*
* this = this* * other*
*
*
* @param other the other frame quaternion to multiply this with. Not modified.
* @throws ReferenceFrameMismatchException if {@code other} is not expressed in the same reference
* frame as {@code this}.
*/
default void multiplyConjugateBoth(FrameQuaternionReadOnly other)
{
checkReferenceFrameMatch(other);
QuaternionBasics.super.multiplyConjugateBoth(other);
}
/**
* Pre-multiplies this frame quaternion by {@code other}.
*
* this = other * this
*
*
* @param other the other frame quaternion to multiply this with. Not modified.
* @throws ReferenceFrameMismatchException if {@code other} is not expressed in the same reference
* frame as {@code this}.
*/
default void preMultiply(FrameQuaternionReadOnly other)
{
checkReferenceFrameMatch(other);
QuaternionBasics.super.preMultiply(other);
}
/**
* Sets this frame quaternion to the multiplication of the conjugate of {@code other} and
* {@code this}.
*
* this = other* * this
*
*
* @param other the other frame quaternion to multiply this with. Not modified.
* @throws ReferenceFrameMismatchException if {@code other} is not expressed in the same reference
* frame as {@code this}.
*/
default void preMultiplyConjugateOther(FrameQuaternionReadOnly other)
{
checkReferenceFrameMatch(other);
QuaternionBasics.super.preMultiplyConjugateOther(other);
}
/**
* Sets this frame quaternion to the multiplication of {@code other} and the conjugate of
* {@code this}.
*
* this = other * this*
*
*
* @param other the other frame quaternion to multiply this with. Not modified.
* @throws ReferenceFrameMismatchException if {@code other} is not expressed in the same reference
* frame as {@code this}.
*/
default void preMultiplyConjugateThis(FrameQuaternionReadOnly other)
{
checkReferenceFrameMatch(other);
QuaternionBasics.super.preMultiplyConjugateThis(other);
}
/**
* Sets this frame quaternion to the multiplication of the conjugate of {@code other} and the
* conjugate of {@code this}.
*
* this = other* * this*
*
*
* @param other the other frame quaternion to multiply this with. Not modified.
* @throws ReferenceFrameMismatchException if {@code other} is not expressed in the same reference
* frame as {@code this}.
*/
default void preMultiplyConjugateBoth(FrameQuaternionReadOnly other)
{
checkReferenceFrameMatch(other);
QuaternionBasics.super.preMultiplyConjugateBoth(other);
}
}