diff options
author | Sven Gothel <[email protected]> | 2014-03-15 05:47:01 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-03-15 05:47:01 +0100 |
commit | e4641e304fbc64a5d185a39c6ca6357cc678e013 (patch) | |
tree | 002f2597b7462f8a510adc3adcd37bafb8d5c1a2 /src/jogl/classes/com/jogamp/opengl/math | |
parent | e2ceb1af352ec73967f2c15341d10fa3069b0a84 (diff) |
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<Outline> in sortOutlines
to avoid reversal of list
- Extract OutlineShapeXForm, pairing { OutlineShape, AffineTransform }
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/math')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/math/Quaternion.java | 37 |
1 files changed, 25 insertions, 12 deletions
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; } |