summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/geom
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-03-15 05:47:01 +0100
committerSven Gothel <[email protected]>2014-03-15 05:47:01 +0100
commite4641e304fbc64a5d185a39c6ca6357cc678e013 (patch)
tree002f2597b7462f8a510adc3adcd37bafb8d5c1a2 /src/jogl/classes/com/jogamp/graph/geom
parente2ceb1af352ec73967f2c15341d10fa3069b0a84 (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/graph/geom')
-rw-r--r--src/jogl/classes/com/jogamp/graph/geom/Outline.java44
1 files changed, 31 insertions, 13 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/geom/Outline.java b/src/jogl/classes/com/jogamp/graph/geom/Outline.java
index 2d9d74966..b299524c0 100644
--- a/src/jogl/classes/com/jogamp/graph/geom/Outline.java
+++ b/src/jogl/classes/com/jogamp/graph/geom/Outline.java
@@ -29,7 +29,10 @@ package com.jogamp.graph.geom;
import java.util.ArrayList;
+import jogamp.graph.geom.plane.AffineTransform;
+
import com.jogamp.graph.geom.Vertex;
+import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.VectorUtil;
import com.jogamp.opengl.math.geom.AABBox;
@@ -181,21 +184,18 @@ public class Outline implements Cloneable, Comparable<Outline> {
return false;
}
- /** Compare two outlines with Bounding Box area
- * as criteria.
- * @see java.lang.Comparable#compareTo(java.lang.Object)
+ /**
+ * Return a transformed instance with all vertices are copied and transformed.
*/
- @Override
- public final int compareTo(Outline outline) {
- float size = getBounds().getSize();
- float newSize = outline.getBounds().getSize();
- if(size < newSize){
- return -1;
- }
- else if(size > newSize){
- return 1;
+ public final Outline transform(AffineTransform t) {
+ final Outline newOutline = new Outline();
+ final int vsize = vertices.size();
+ for(int i=0; i<vsize; i++) {
+ final Vertex v = vertices.get(i);
+ newOutline.addVertex(t.transform(v, null));
}
- return 0;
+ newOutline.closed = this.closed;
+ return newOutline;
}
private final void validateBoundingBox() {
@@ -214,6 +214,24 @@ public class Outline implements Cloneable, Comparable<Outline> {
}
/**
+ * Compare two outline's Bounding Box size.
+ * @see AABBox#getSize()
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public final int compareTo(final Outline other) {
+ final float thisSize = getBounds().getSize();
+ final float otherSize = other.getBounds().getSize();
+ if( FloatUtil.equals(thisSize, otherSize, FloatUtil.EPSILON) ) {
+ return 0;
+ } else if(thisSize < otherSize){
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+
+ /**
* @param obj the Object to compare this Outline with
* @return true if {@code obj} is an Outline, not null, equals bounds and equal vertices in the same order
*/