You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2012/06/18 12:13:40 UTC
svn commit: r1351265 - in
/commons/proper/math/trunk/src/main/java/org/apache/commons/math3:
analysis/interpolation/HermiteInterpolator.java
geometry/euclidean/threed/Rotation.java
Author: luc
Date: Mon Jun 18 10:13:40 2012
New Revision: 1351265
URL: http://svn.apache.org/viewvc?rev=1351265&view=rev
Log:
Fixed checkstyle warnings.
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/HermiteInterpolator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Rotation.java
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/HermiteInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/HermiteInterpolator.java?rev=1351265&r1=1351264&r2=1351265&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/HermiteInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/HermiteInterpolator.java Mon Jun 18 10:13:40 2012
@@ -229,7 +229,7 @@ public class HermiteInterpolator impleme
public double[] value(double x) {
return derivative(x);
}
-
+
};
}
@@ -237,7 +237,7 @@ public class HermiteInterpolator impleme
* @exception MathIllegalStateException if interpolation cannot be performed
* because sample is empty
*/
- private void checkInterpolation() throws MathIllegalStateException {
+ private void checkInterpolation() throws MathIllegalStateException {
if (abscissae.isEmpty()) {
throw new MathIllegalStateException(LocalizedFormats.EMPTY_INTERPOLATION_SAMPLE);
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Rotation.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Rotation.java?rev=1351265&r1=1351264&r2=1351265&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Rotation.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Rotation.java Mon Jun 18 10:13:40 2012
@@ -250,67 +250,6 @@ public class Rotation implements Seriali
}
- /** 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.
* <p>Except for possible scale factors, if the instance were applied to
@@ -446,6 +385,67 @@ public class Rotation implements Seriali
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.
* Build a rotation which reverse the effect of another
* rotation. This means that if r(u) = v, then r.revert(v) = u. The