mirror of
https://github.com/apache/commons-math.git
synced 2025-02-08 02:59:36 +00:00
Fixed checkstyle warnings.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1351265 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e8a6708cfd
commit
52eb62e4dd
@ -229,7 +229,7 @@ public class HermiteInterpolator implements DifferentiableUnivariateVectorFuncti
|
|||||||
public double[] value(double x) {
|
public double[] value(double x) {
|
||||||
return derivative(x);
|
return derivative(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ public class HermiteInterpolator implements DifferentiableUnivariateVectorFuncti
|
|||||||
* @exception MathIllegalStateException if interpolation cannot be performed
|
* @exception MathIllegalStateException if interpolation cannot be performed
|
||||||
* because sample is empty
|
* because sample is empty
|
||||||
*/
|
*/
|
||||||
private void checkInterpolation() throws MathIllegalStateException {
|
private void checkInterpolation() throws MathIllegalStateException {
|
||||||
if (abscissae.isEmpty()) {
|
if (abscissae.isEmpty()) {
|
||||||
throw new MathIllegalStateException(LocalizedFormats.EMPTY_INTERPOLATION_SAMPLE);
|
throw new MathIllegalStateException(LocalizedFormats.EMPTY_INTERPOLATION_SAMPLE);
|
||||||
}
|
}
|
||||||
|
@ -250,67 +250,6 @@ public class Rotation implements Serializable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convert an orthogonal rotation matrix to a quaternion.
|
|
||||||
* @param ort orthogonal rotation matrix
|
|
||||||
* @return quaternion corresponding to the matrix
|
|
||||||
*/
|
|
||||||
private static double[] mat2quat(final double[][] ort) {
|
|
||||||
|
|
||||||
final double[] quat = new double[4];
|
|
||||||
|
|
||||||
// There are different ways to compute the quaternions elements
|
|
||||||
// from the matrix. They all involve computing one element from
|
|
||||||
// the diagonal of the matrix, and computing the three other ones
|
|
||||||
// using a formula involving a division by the first element,
|
|
||||||
// which unfortunately can be zero. Since the norm of the
|
|
||||||
// quaternion is 1, we know at least one element has an absolute
|
|
||||||
// value greater or equal to 0.5, so it is always possible to
|
|
||||||
// select the right formula and avoid division by zero and even
|
|
||||||
// numerical inaccuracy. Checking the elements in turn and using
|
|
||||||
// the first one greater than 0.45 is safe (this leads to a simple
|
|
||||||
// test since qi = 0.45 implies 4 qi^2 - 1 = -0.19)
|
|
||||||
double s = ort[0][0] + ort[1][1] + ort[2][2];
|
|
||||||
if (s > -0.19) {
|
|
||||||
// compute q0 and deduce q1, q2 and q3
|
|
||||||
quat[0] = 0.5 * FastMath.sqrt(s + 1.0);
|
|
||||||
double inv = 0.25 / quat[0];
|
|
||||||
quat[1] = inv * (ort[1][2] - ort[2][1]);
|
|
||||||
quat[2] = inv * (ort[2][0] - ort[0][2]);
|
|
||||||
quat[3] = inv * (ort[0][1] - ort[1][0]);
|
|
||||||
} else {
|
|
||||||
s = ort[0][0] - ort[1][1] - ort[2][2];
|
|
||||||
if (s > -0.19) {
|
|
||||||
// compute q1 and deduce q0, q2 and q3
|
|
||||||
quat[1] = 0.5 * FastMath.sqrt(s + 1.0);
|
|
||||||
double inv = 0.25 / quat[1];
|
|
||||||
quat[0] = inv * (ort[1][2] - ort[2][1]);
|
|
||||||
quat[2] = inv * (ort[0][1] + ort[1][0]);
|
|
||||||
quat[3] = inv * (ort[0][2] + ort[2][0]);
|
|
||||||
} else {
|
|
||||||
s = ort[1][1] - ort[0][0] - ort[2][2];
|
|
||||||
if (s > -0.19) {
|
|
||||||
// compute q2 and deduce q0, q1 and q3
|
|
||||||
quat[2] = 0.5 * FastMath.sqrt(s + 1.0);
|
|
||||||
double inv = 0.25 / quat[2];
|
|
||||||
quat[0] = inv * (ort[2][0] - ort[0][2]);
|
|
||||||
quat[1] = inv * (ort[0][1] + ort[1][0]);
|
|
||||||
quat[3] = inv * (ort[2][1] + ort[1][2]);
|
|
||||||
} else {
|
|
||||||
// compute q3 and deduce q0, q1 and q2
|
|
||||||
s = ort[2][2] - ort[0][0] - ort[1][1];
|
|
||||||
quat[3] = 0.5 * FastMath.sqrt(s + 1.0);
|
|
||||||
double inv = 0.25 / quat[3];
|
|
||||||
quat[0] = inv * (ort[0][1] - ort[1][0]);
|
|
||||||
quat[1] = inv * (ort[0][2] + ort[2][0]);
|
|
||||||
quat[2] = inv * (ort[2][1] + ort[1][2]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return quat;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Build the rotation that transforms a pair of vector into another pair.
|
/** Build the rotation that transforms a pair of vector into another pair.
|
||||||
|
|
||||||
* <p>Except for possible scale factors, if the instance were applied to
|
* <p>Except for possible scale factors, if the instance were applied to
|
||||||
@ -446,6 +385,67 @@ public class Rotation implements Serializable {
|
|||||||
q3 = composed.q3;
|
q3 = composed.q3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Convert an orthogonal rotation matrix to a quaternion.
|
||||||
|
* @param ort orthogonal rotation matrix
|
||||||
|
* @return quaternion corresponding to the matrix
|
||||||
|
*/
|
||||||
|
private static double[] mat2quat(final double[][] ort) {
|
||||||
|
|
||||||
|
final double[] quat = new double[4];
|
||||||
|
|
||||||
|
// There are different ways to compute the quaternions elements
|
||||||
|
// from the matrix. They all involve computing one element from
|
||||||
|
// the diagonal of the matrix, and computing the three other ones
|
||||||
|
// using a formula involving a division by the first element,
|
||||||
|
// which unfortunately can be zero. Since the norm of the
|
||||||
|
// quaternion is 1, we know at least one element has an absolute
|
||||||
|
// value greater or equal to 0.5, so it is always possible to
|
||||||
|
// select the right formula and avoid division by zero and even
|
||||||
|
// numerical inaccuracy. Checking the elements in turn and using
|
||||||
|
// the first one greater than 0.45 is safe (this leads to a simple
|
||||||
|
// test since qi = 0.45 implies 4 qi^2 - 1 = -0.19)
|
||||||
|
double s = ort[0][0] + ort[1][1] + ort[2][2];
|
||||||
|
if (s > -0.19) {
|
||||||
|
// compute q0 and deduce q1, q2 and q3
|
||||||
|
quat[0] = 0.5 * FastMath.sqrt(s + 1.0);
|
||||||
|
double inv = 0.25 / quat[0];
|
||||||
|
quat[1] = inv * (ort[1][2] - ort[2][1]);
|
||||||
|
quat[2] = inv * (ort[2][0] - ort[0][2]);
|
||||||
|
quat[3] = inv * (ort[0][1] - ort[1][0]);
|
||||||
|
} else {
|
||||||
|
s = ort[0][0] - ort[1][1] - ort[2][2];
|
||||||
|
if (s > -0.19) {
|
||||||
|
// compute q1 and deduce q0, q2 and q3
|
||||||
|
quat[1] = 0.5 * FastMath.sqrt(s + 1.0);
|
||||||
|
double inv = 0.25 / quat[1];
|
||||||
|
quat[0] = inv * (ort[1][2] - ort[2][1]);
|
||||||
|
quat[2] = inv * (ort[0][1] + ort[1][0]);
|
||||||
|
quat[3] = inv * (ort[0][2] + ort[2][0]);
|
||||||
|
} else {
|
||||||
|
s = ort[1][1] - ort[0][0] - ort[2][2];
|
||||||
|
if (s > -0.19) {
|
||||||
|
// compute q2 and deduce q0, q1 and q3
|
||||||
|
quat[2] = 0.5 * FastMath.sqrt(s + 1.0);
|
||||||
|
double inv = 0.25 / quat[2];
|
||||||
|
quat[0] = inv * (ort[2][0] - ort[0][2]);
|
||||||
|
quat[1] = inv * (ort[0][1] + ort[1][0]);
|
||||||
|
quat[3] = inv * (ort[2][1] + ort[1][2]);
|
||||||
|
} else {
|
||||||
|
// compute q3 and deduce q0, q1 and q2
|
||||||
|
s = ort[2][2] - ort[0][0] - ort[1][1];
|
||||||
|
quat[3] = 0.5 * FastMath.sqrt(s + 1.0);
|
||||||
|
double inv = 0.25 / quat[3];
|
||||||
|
quat[0] = inv * (ort[0][1] - ort[1][0]);
|
||||||
|
quat[1] = inv * (ort[0][2] + ort[2][0]);
|
||||||
|
quat[2] = inv * (ort[2][1] + ort[1][2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return quat;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/** Revert a rotation.
|
/** Revert a rotation.
|
||||||
* Build a rotation which reverse the effect of another
|
* Build a rotation which reverse the effect of another
|
||||||
* rotation. This means that if r(u) = v, then r.revert(v) = u. The
|
* rotation. This means that if r(u) = v, then r.revert(v) = u. The
|
||||||
|
Loading…
x
Reference in New Issue
Block a user