From ee774dce9e474e8ea961bd9b504d26e9321e1b15 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 28 Jun 2014 03:02:25 +0200 Subject: Enhance FloatUtil: More optimizations, concludes commit 0bded476868c5fdfe44502bfd55957469d0d72bb FloatUtil optimizations (unroll and linear memeory access): - transposeMatrix - invertMatrix (diff algo as well - 50% speed bump) - multMatrix - multMatrixVec FloatUtil added - matrixDeterminant(..) FloatUtil removed - Certain FloatBuffer variants are removed or at least marked deprecated. --- .../classes/com/jogamp/opengl/math/Quaternion.java | 92 +--------------------- 1 file changed, 1 insertion(+), 91 deletions(-) (limited to 'src/jogl/classes/com/jogamp/opengl/math/Quaternion.java') diff --git a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java index 502da42c2..243ab2a33 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java +++ b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java @@ -27,8 +27,6 @@ */ package com.jogamp.opengl.math; -import java.nio.FloatBuffer; - /** * Quaternion implementation supporting * Gimbal-Lock free rotations. @@ -50,7 +48,7 @@ public class Quaternion { /** * Quaternion Epsilon, used with equals method to determine if two Quaternions are close enough to be considered equal. *

- * Using {@value}, which is ~20 times {@link FloatUtil#EPSILON}. + * Using {@value}, which is ~10 times {@link FloatUtil#EPSILON}. *

*/ public static final float ALLOWED_DEVIANCE = 1.0E-6f; // FloatUtil.EPSILON == 1.1920929E-7f; double ALLOWED_DEVIANCE: 1.0E-8f @@ -942,27 +940,6 @@ public class Quaternion { m[2+0*4+m_off], m[2+1*4+m_off], m[2+2*4+m_off]); } - /** - * Initializes this quaternion from a 4x4 column rotation matrix - *

- * See Graphics Gems Code,
- * MatrixTrace. - *

- *

- * Buggy Matrix-FAQ Q55 - *

- * - * @param m 4x4 column matrix - * @return this quaternion for chaining. - * @see #toMatrix(FloatBuffer) - */ - public final Quaternion setFromMatrix(final FloatBuffer m) { - final int m_off = m.position(); - return setFromMatrix(m.get(0+0*4+m_off), m.get(0+1*4+m_off), m.get(0+2*4+m_off), - m.get(1+0*4+m_off), m.get(1+1*4+m_off), m.get(1+2*4+m_off), - m.get(2+0*4+m_off), m.get(2+1*4+m_off), m.get(2+2*4+m_off)); - } - /** * Compute the quaternion from a 3x3 column rotation matrix *

@@ -1083,73 +1060,6 @@ public class Quaternion { return matrix; } - /** - * Transform this quaternion to a normalized 4x4 column matrix representing the rotation. - *

- * Implementation Details: - *

- *

- * - * @param matrix FloatBuffer store for the resulting normalized column matrix 4x4 - * @param mat_offset - * @return the given matrix store - * @see Matrix-FAQ Q54 - * @see #setFromMatrix(FloatBuffer) - */ - public final FloatBuffer toMatrix(final FloatBuffer matrix) { - final int mat_offset = matrix.position(); - - // pre-multipliy scaled-reciprocal-magnitude to reduce multiplications - final float norm = magnitudeSquared(); - if ( FloatUtil.isZero(norm, FloatUtil.EPSILON) ) { - // identity matrix -> srecip = 0f - return FloatUtil.makeIdentity(matrix); - } - final float srecip; - if ( FloatUtil.isEqual(1f, norm, FloatUtil.EPSILON) ) { - srecip = 2f; - } else { - srecip = 2.0f / norm; - } - - final float xs = srecip * x; - final float ys = srecip * y; - final float zs = srecip * z; - - final float xx = x * xs; - final float xy = x * ys; - final float xz = x * zs; - final float xw = xs * w; - final float yy = y * ys; - final float yz = y * zs; - final float yw = ys * w; - final float zz = z * zs; - final float zw = zs * w; - - matrix.put(0+0*4+mat_offset, 1f - ( yy + zz )); - matrix.put(0+1*4+mat_offset, ( xy - zw )); - matrix.put(0+2*4+mat_offset, ( xz + yw )); - matrix.put(0+3*4+mat_offset, 0f); - - matrix.put(1+0*4+mat_offset, ( xy + zw )); - matrix.put(1+1*4+mat_offset, 1f - ( xx + zz )); - matrix.put(1+2*4+mat_offset, ( yz - xw )); - matrix.put(1+3*4+mat_offset, 0f); - - matrix.put(2+0*4+mat_offset, ( xz - yw )); - matrix.put(2+1*4+mat_offset, ( yz + xw )); - matrix.put(2+2*4+mat_offset, 1f - ( xx + yy )); - matrix.put(2+3*4+mat_offset, 0f); - - matrix.put(3+0*4+mat_offset, 0f); - matrix.put(3+1*4+mat_offset, 0f); - matrix.put(3+2*4+mat_offset, 0f); - matrix.put(3+3*4+mat_offset, 1f); - return matrix; - } - /** * @param index the 3x3 rotation matrix column to retrieve from this quaternion (normalized). Must be between 0 and 2. * @param result the vector object to store the result in. -- cgit v1.2.3