本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.ZERO_NORM_FOR_ROTATION_AXIS属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.ZERO_NORM_FOR_ROTATION_AXIS属性的具体用法?Java LocalizedFormats.ZERO_NORM_FOR_ROTATION_AXIS怎么用?Java LocalizedFormats.ZERO_NORM_FOR_ROTATION_AXIS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.math3.exception.util.LocalizedFormats
的用法示例。
在下文中一共展示了LocalizedFormats.ZERO_NORM_FOR_ROTATION_AXIS属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Rotation
/** Build a rotation from an axis and an angle.
* @param axis axis around which to rotate
* @param angle rotation angle
* @param convention convention to use for the semantics of the angle
* @exception MathIllegalArgumentException if the axis norm is zero
* @since 3.6
*/
public Rotation(final Vector3D axis, final double angle, final RotationConvention convention)
throws MathIllegalArgumentException {
double norm = axis.getNorm();
if (norm == 0) {
throw new MathIllegalArgumentException(LocalizedFormats.ZERO_NORM_FOR_ROTATION_AXIS);
}
double halfAngle = convention == RotationConvention.VECTOR_OPERATOR ? -0.5 * angle : +0.5 * angle;
double coeff = FastMath.sin(halfAngle) / norm;
q0 = FastMath.cos (halfAngle);
q1 = coeff * axis.getX();
q2 = coeff * axis.getY();
q3 = coeff * axis.getZ();
}
示例2: FieldRotation
/** Build a rotation from an axis and an angle.
* <p>We use the convention that angles are oriented according to
* the effect of the rotation on vectors around the axis. That means
* that if (i, j, k) is a direct frame and if we first provide +k as
* the axis and π/2 as the angle to this constructor, and then
* {@link #applyTo(FieldVector3D) apply} the instance to +i, we will get
* +j.</p>
* <p>Another way to represent our convention is to say that a rotation
* of angle θ about the unit vector (x, y, z) is the same as the
* rotation build from quaternion components { cos(-θ/2),
* x * sin(-θ/2), y * sin(-θ/2), z * sin(-θ/2) }.
* Note the minus sign on the angle!</p>
* <p>On the one hand this convention is consistent with a vectorial
* perspective (moving vectors in fixed frames), on the other hand it
* is different from conventions with a frame perspective (fixed vectors
* viewed from different frames) like the ones used for example in spacecraft
* attitude community or in the graphics community.</p>
* @param axis axis around which to rotate
* @param angle rotation angle.
* @param convention convention to use for the semantics of the angle
* @exception MathIllegalArgumentException if the axis norm is zero
* @since 3.6
*/
public FieldRotation(final FieldVector3D<T> axis, final T angle, final RotationConvention convention)
throws MathIllegalArgumentException {
final T norm = axis.getNorm();
if (norm.getReal() == 0) {
throw new MathIllegalArgumentException(LocalizedFormats.ZERO_NORM_FOR_ROTATION_AXIS);
}
final T halfAngle = angle.multiply(convention == RotationConvention.VECTOR_OPERATOR ? -0.5 : 0.5);
final T coeff = halfAngle.sin().divide(norm);
q0 = halfAngle.cos();
q1 = coeff.multiply(axis.getX());
q2 = coeff.multiply(axis.getY());
q3 = coeff.multiply(axis.getZ());
}