From e4641e304fbc64a5d185a39c6ca6357cc678e013 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 15 Mar 2014 05:47:01 +0100 Subject: Bug 801: Outline/OutlineShape tranform and sort fixes ; Quaternion: Reduce muls in rotateVector Quaternion: - rotateVector(..): Reduce multiplication count by 17 Graph: - Outline - add: transform - fix compareTo .. use EPSILON - OutlineShape - add transform - fix compareTo .. use EPSILON - use Comparator in sortOutlines to avoid reversal of list - Extract OutlineShapeXForm, pairing { OutlineShape, AffineTransform } --- .../classes/com/jogamp/opengl/math/Quaternion.java | 37 +++++++++++++++------- 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'src/jogl/classes/com/jogamp/opengl/math') diff --git a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java index ab419e3cd..56d270380 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java +++ b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java @@ -380,18 +380,31 @@ public class Quaternion { final float vecX = vecIn[0+vecInOffset]; final float vecY = vecIn[1+vecInOffset]; final float vecZ = vecIn[2+vecInOffset]; - vecOut[0+vecOutOffset] = w * w * vecX + 2f * y * w * vecZ - - 2f * z * w * vecY + x * x * vecX - + 2f * y * x * vecY + 2f * z * x * vecZ - - z * z * vecX - y * y * vecX; - vecOut[1+vecOutOffset] = 2f * x * y * vecX + y * y * vecY - + 2f * z * y * vecZ + 2f * w * z * vecX - - z * z * vecY + w * w * vecY - - 2f * x * w * vecZ - x * x * vecY; - vecOut[2+vecOutOffset] = 2f * x * z * vecX + 2f * y * z * vecY - + z * z * vecZ - 2f * w * y * vecX - - y * y * vecZ + 2f * w * x * vecY - - x * x * vecZ + w * w * vecZ; + final float x_x = x*x; + final float y_y = y*y; + final float z_z = z*z; + final float w_w = w*w; + + vecOut[0+vecOutOffset] = w_w * vecX + + x_x * vecX + - z_z * vecX + - y_y * vecX + + 2f * ( y*w*vecZ - z*w*vecY + y*x*vecY + z*x*vecZ ); + ; + + vecOut[1+vecOutOffset] = y_y * vecY + - z_z * vecY + + w_w * vecY + - x_x * vecY + + 2f * ( x*y*vecX + z*y*vecZ + w*z*vecX - x*w*vecZ ); + ; + + vecOut[2+vecOutOffset] = z_z * vecZ + - y_y * vecZ + - x_x * vecZ + + w_w * vecZ + + 2f * ( x*z*vecX + y*z*vecY - w*y*vecX + w*x*vecY ); + ; } return vecOut; } -- cgit v1.2.3