diff options
author | Sven Gothel <[email protected]> | 2012-11-11 05:01:56 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-11-11 05:01:56 +0100 |
commit | 5fafc1ac360333645b807dcd8dff0c0a655ea439 (patch) | |
tree | c3c0af31dc6cc9a10e381151e5461bb2e033488a /src/jogl | |
parent | 0edb45f11cd034c4937e6941b7a3e5d9f7edbd2f (diff) |
Reorganize math code into: com.jogamp.opengl.math and com.jogamp.opengl.math.geom packages
Note: WIP - We may relocate / reorg math package.
Public relocations:
com.jogamp.opengl.util -> com.jogamp.opengl.math
- FixedPoint
- FloatUtil
com.jogamp.graph.math -> com.jogamp.opengl.math
- Quaternion
- VectorUtil
com.jogamp.graph.geom -> com.jogamp.opengl.math.geom
- AABBox
VectorUtil:
Introducing Vert2fImmutable and Vert3fImmutable interfaces, allowing graph Vertex instances
to be used 'graph' agnostic and to document 2d/3d use-cases.
Diffstat (limited to 'src/jogl')
27 files changed, 257 insertions, 82 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java index e60fba02b..a3749788b 100755 --- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java +++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java @@ -32,11 +32,11 @@ import java.util.Collections; import com.jogamp.graph.curve.tess.Triangulation; import com.jogamp.graph.curve.tess.Triangulator; -import com.jogamp.graph.geom.AABBox; import com.jogamp.graph.geom.Outline; import com.jogamp.graph.geom.Triangle; import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.math.VectorUtil; +import com.jogamp.opengl.math.VectorUtil; +import com.jogamp.opengl.math.geom.AABBox; /** A Generic shape objects which is defined by a list of Outlines. diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java index af15f9dc4..8b6d000fa 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/Region.java +++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java @@ -31,9 +31,9 @@ import java.util.ArrayList; import jogamp.opengl.Debug; -import com.jogamp.graph.geom.AABBox; import com.jogamp.graph.geom.Triangle; import com.jogamp.graph.geom.Vertex; +import com.jogamp.opengl.math.geom.AABBox; /** Abstract Outline shape GL representation * define the method an OutlineShape(s) is diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java index e2b3fe5d7..64a3a3e6c 100644 --- a/src/jogl/classes/com/jogamp/graph/font/Font.java +++ b/src/jogl/classes/com/jogamp/graph/font/Font.java @@ -27,7 +27,7 @@ */ package com.jogamp.graph.font; -import com.jogamp.graph.geom.AABBox; +import com.jogamp.opengl.math.geom.AABBox; /** * Interface wrapper for font implementation. diff --git a/src/jogl/classes/com/jogamp/graph/geom/Outline.java b/src/jogl/classes/com/jogamp/graph/geom/Outline.java index 5030488cc..12c45860b 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Outline.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Outline.java @@ -30,7 +30,8 @@ package com.jogamp.graph.geom; import java.util.ArrayList; import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.math.VectorUtil; +import com.jogamp.opengl.math.VectorUtil; +import com.jogamp.opengl.math.geom.AABBox; diff --git a/src/jogl/classes/com/jogamp/graph/geom/Vertex.java b/src/jogl/classes/com/jogamp/graph/geom/Vertex.java index 3080f32cc..e3df86de1 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Vertex.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Vertex.java @@ -27,10 +27,12 @@ */ package com.jogamp.graph.geom; +import com.jogamp.opengl.math.Vert3fImmutable; + /** * A Vertex with custom memory layout using custom factory. */ -public interface Vertex extends Cloneable { +public interface Vertex extends Vert3fImmutable, Cloneable { public static interface Factory <T extends Vertex> { T create(); @@ -47,20 +49,12 @@ public interface Vertex extends Cloneable { */ void setCoord(float[] coordsBuffer, int offset, int length); - float[] getCoord(); - void setX(float x); void setY(float y); void setZ(float z); - float getX(); - - float getY(); - - float getZ(); - boolean isOnCurve(); void setOnCurve(boolean onCurve); diff --git a/src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java b/src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java index 9dade17e9..97e438b63 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java +++ b/src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java @@ -28,7 +28,7 @@ package com.jogamp.graph.geom.opengl; import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.math.VectorUtil; +import com.jogamp.opengl.math.VectorUtil; /** A Simple Vertex Implementation. Where the coordinates, and other attributes are * float based, and the coordinates and texture coordinates are saved in two float arrays. @@ -88,6 +88,12 @@ public class SVertex implements Vertex { System.arraycopy(coordsBuffer, offset, coord, 0, length); } + @Override + public int getCoordCount() { + return 3; + } + + @Override public final float[] getCoord() { return coord; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/FixedPoint.java b/src/jogl/classes/com/jogamp/opengl/math/FixedPoint.java index 6412db5ef..e0acfec28 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/FixedPoint.java +++ b/src/jogl/classes/com/jogamp/opengl/math/FixedPoint.java @@ -31,7 +31,7 @@ * */ -package com.jogamp.opengl.util; +package com.jogamp.opengl.math; public class FixedPoint { public static final int toFixed(int value) { diff --git a/src/jogl/classes/com/jogamp/opengl/FloatUtil.java b/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java index 16e8b1455..9a51c32b3 100644 --- a/src/jogl/classes/com/jogamp/opengl/FloatUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java @@ -25,7 +25,7 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.opengl; +package com.jogamp.opengl.math; import java.nio.FloatBuffer; @@ -166,6 +166,23 @@ public class FloatUtil { } } + /** + * @param a 4x4 matrix in column-major order + * @param b 4x4 matrix in column-major order + * @param d result a*b in column-major order + */ + public static final void multMatrixf(final FloatBuffer a, final FloatBuffer b, float[] d, int d_off) { + final int aP = a.position(); + final int bP = b.position(); + for (int i = 0; i < 4; i++) { + // one row in column-major order + final float ai0=a.get(aP+i+0*4), ai1=a.get(aP+i+1*4), ai2=a.get(aP+i+2*4), ai3=a.get(aP+i+3*4); // row-i of a + d[d_off+i+0*4] = ai0 * b.get(bP+0+0*4) + ai1 * b.get(bP+1+0*4) + ai2 * b.get(bP+2+0*4) + ai3 * b.get(bP+3+0*4) ; + d[d_off+i+1*4] = ai0 * b.get(bP+0+1*4) + ai1 * b.get(bP+1+1*4) + ai2 * b.get(bP+2+1*4) + ai3 * b.get(bP+3+1*4) ; + d[d_off+i+2*4] = ai0 * b.get(bP+0+2*4) + ai1 * b.get(bP+1+2*4) + ai2 * b.get(bP+2+2*4) + ai3 * b.get(bP+3+2*4) ; + d[d_off+i+3*4] = ai0 * b.get(bP+0+3*4) + ai1 * b.get(bP+1+3*4) + ai2 * b.get(bP+2+3*4) + ai3 * b.get(bP+3+3*4) ; + } + } /** * Normalize vector @@ -357,6 +374,33 @@ public class FloatUtil { /** * @param sb optional passed StringBuilder instance to be used + * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter} + * @param a mxn matrix (rows x columns) + * @param aOffset offset to <code>a</code>'s current position + * @param rows + * @param columns + * @param rowMajorOrder if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL) + * @param row row number to print + * @return matrix row string representation + */ + public static StringBuilder matrixRowToString(StringBuilder sb, String f, float[] a, int aOffset, int rows, int columns, boolean rowMajorOrder, int row) { + if(null == sb) { + sb = new StringBuilder(); + } + if(rowMajorOrder) { + for(int c=0; c<columns; c++) { + sb.append( String.format( f+" ", a[ aOffset + row*columns + c ] ) ); + } + } else { + for(int r=0; r<columns; r++) { + sb.append( String.format( f+" ", a[ aOffset + row + r*rows ] ) ); + } + } + return sb; + } + + /** + * @param sb optional passed StringBuilder instance to be used * @param rowPrefix optional prefix for each row * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter} * @param a mxn matrix (rows x columns) @@ -383,6 +427,30 @@ public class FloatUtil { * @param sb optional passed StringBuilder instance to be used * @param rowPrefix optional prefix for each row * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter} + * @param a mxn matrix (rows x columns) + * @param aOffset offset to <code>a</code>'s current position + * @param rows + * @param columns + * @param rowMajorOrder if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL) + * @return matrix string representation + */ + public static StringBuilder matrixToString(StringBuilder sb, String rowPrefix, String f, float[] a, int aOffset, int rows, int columns, boolean rowMajorOrder) { + if(null == sb) { + sb = new StringBuilder(); + } + final String prefix = ( null == rowPrefix ) ? "" : rowPrefix; + for(int i=0; i<rows; i++) { + sb.append(prefix).append("[ "); + matrixRowToString(sb, f, a, aOffset, rows, columns, rowMajorOrder, i); + sb.append("]").append(Platform.getNewline()); + } + return sb; + } + + /** + * @param sb optional passed StringBuilder instance to be used + * @param rowPrefix optional prefix for each row + * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter} * @param a 4x4 matrix in column major order (OpenGL) * @param aOffset offset to <code>a</code>'s current position * @param b 4x4 matrix in column major order (OpenGL) @@ -407,6 +475,34 @@ public class FloatUtil { return sb; } + /** + * @param sb optional passed StringBuilder instance to be used + * @param rowPrefix optional prefix for each row + * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter} + * @param a 4x4 matrix in column major order (OpenGL) + * @param aOffset offset to <code>a</code>'s current position + * @param b 4x4 matrix in column major order (OpenGL) + * @param bOffset offset to <code>a</code>'s current position + * @param rows + * @param columns + * @param rowMajorOrder if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL) + * @return side by side representation + */ + public static StringBuilder matrixToString(StringBuilder sb, String rowPrefix, String f, float[] a, int aOffset, float[] b, int bOffset, int rows, int columns, boolean rowMajorOrder) { + if(null == sb) { + sb = new StringBuilder(); + } + final String prefix = ( null == rowPrefix ) ? "" : rowPrefix; + for(int i=0; i<rows; i++) { + sb.append(prefix).append("[ "); + matrixRowToString(sb, f, a, aOffset, rows, columns, rowMajorOrder, i); + sb.append("=?= "); + matrixRowToString(sb, f, b, bOffset, rows, columns, rowMajorOrder, i); + sb.append("]").append(Platform.getNewline()); + } + return sb; + } + public static final float E = 2.7182818284590452354f; public static final float PI = 3.14159265358979323846f; diff --git a/src/jogl/classes/com/jogamp/graph/math/Quaternion.java b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java index cbdf52dff..7a753d18d 100755 --- a/src/jogl/classes/com/jogamp/graph/math/Quaternion.java +++ b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java @@ -25,9 +25,8 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.graph.math; +package com.jogamp.opengl.math; -import com.jogamp.opengl.FloatUtil; public class Quaternion { diff --git a/src/jogl/classes/com/jogamp/graph/math/VectorUtil.java b/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java index 540e901b8..5a75d016a 100755 --- a/src/jogl/classes/com/jogamp/graph/math/VectorUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java @@ -25,14 +25,10 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.graph.math; +package com.jogamp.opengl.math; import java.util.ArrayList; - -import com.jogamp.graph.geom.Vertex; -import com.jogamp.opengl.FloatUtil; - public class VectorUtil { public enum Winding { @@ -62,9 +58,9 @@ public class VectorUtil { */ public static float[] normalize(float[] vector) { - float[] newVector = new float[3]; + final float[] newVector = new float[3]; - float d = FloatUtil.sqrt(vector[0]*vector[0] + vector[1]*vector[1] + vector[2]*vector[2]); + final float d = FloatUtil.sqrt(vector[0]*vector[0] + vector[1]*vector[1] + vector[2]*vector[2]); if(d> 0.0f) { newVector[0] = vector[0]/d; @@ -81,7 +77,7 @@ public class VectorUtil { */ public static float[] scale(float[] vector, float scale) { - float[] newVector = new float[3]; + final float[] newVector = new float[3]; newVector[0] = vector[0]*scale; newVector[1] = vector[1]*scale; @@ -96,7 +92,7 @@ public class VectorUtil { */ public static float[] vectorAdd(float[] v1, float[] v2) { - float[] newVector = new float[3]; + final float[] newVector = new float[3]; newVector[0] = v1[0] + v2[0]; newVector[1] = v1[1] + v2[1]; @@ -111,7 +107,7 @@ public class VectorUtil { */ public static float[] cross(float[] vec1, float[] vec2) { - float[] out = new float[3]; + final float[] out = new float[3]; out[0] = vec2[2]*vec1[1] - vec2[1]*vec1[2]; out[1] = vec2[0]*vec1[2] - vec2[2]*vec1[0]; @@ -127,7 +123,7 @@ public class VectorUtil { */ public static float[] colMatrixVectorMult(float[] colMatrix, float[] vec) { - float[] out = new float[3]; + final float[] out = new float[3]; out[0] = vec[0]*colMatrix[0] + vec[1]*colMatrix[4] + vec[2]*colMatrix[8] + colMatrix[12]; out[1] = vec[0]*colMatrix[1] + vec[1]*colMatrix[5] + vec[2]*colMatrix[9] + colMatrix[13]; @@ -143,7 +139,7 @@ public class VectorUtil { */ public static float[] rowMatrixVectorMult(float[] rawMatrix, float[] vec) { - float[] out = new float[3]; + final float[] out = new float[3]; out[0] = vec[0]*rawMatrix[0] + vec[1]*rawMatrix[1] + vec[2]*rawMatrix[2] + rawMatrix[3]; out[1] = vec[0]*rawMatrix[4] + vec[1]*rawMatrix[5] + vec[2]*rawMatrix[6] + rawMatrix[7]; @@ -161,6 +157,7 @@ public class VectorUtil { { return (p1+p2)/2.0f; } + /** Calculate the midpoint of two points * @param p1 first point * @param p2 second point @@ -168,13 +165,14 @@ public class VectorUtil { */ public static float[] mid(float[] p1, float[] p2) { - float[] midPoint = new float[3]; + final float[] midPoint = new float[3]; midPoint[0] = (p1[0] + p2[0])*0.5f; midPoint[1] = (p1[1] + p2[1])*0.5f; midPoint[2] = (p1[2] + p2[2])*0.5f; return midPoint; } + /** Compute the norm of a vector * @param vec vector * @return vorm @@ -183,6 +181,7 @@ public class VectorUtil { { return FloatUtil.sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]); } + /** Compute distance between 2 points * @param p0 a ref point on the line * @param vec vector representing the direction of the line @@ -191,11 +190,11 @@ public class VectorUtil { */ public static float computeLength(float[] p0, float[] point) { - float[] w = new float[]{point[0]-p0[0],point[1]-p0[1],point[2]-p0[2]}; + final float w0 = point[0]-p0[0]; + final float w1 = point[1]-p0[1]; + final float w2 = point[2]-p0[2]; - float distance = FloatUtil.sqrt(w[0]*w[0] + w[1]*w[1] + w[2]*w[2]); - - return distance; + return FloatUtil.sqrt(w0*w0 + w1*w1 + w2*w2); } /**Check equality of 2 vec3 vectors @@ -205,11 +204,9 @@ public class VectorUtil { */ public static boolean checkEquality(float[] v1, float[] v2) { - if(Float.compare(v1[0], v2[0]) == 0 && - Float.compare(v1[1], v2[1]) == 0 && - Float.compare(v1[2], v2[2]) == 0 ) - return true; - return false; + return Float.compare(v1[0], v2[0]) == 0 && + Float.compare(v1[1], v2[1]) == 0 && + Float.compare(v1[2], v2[2]) == 0 ; } /**Check equality of 2 vec2 vectors @@ -219,10 +216,8 @@ public class VectorUtil { */ public static boolean checkEqualityVec2(float[] v1, float[] v2) { - if(Float.compare(v1[0], v2[0]) == 0 && - Float.compare(v1[1], v2[1]) == 0) - return true; - return false; + return Float.compare(v1[0], v2[0]) == 0 && + Float.compare(v1[1], v2[1]) == 0 ; } /** Compute the determinant of 3 vectors @@ -233,8 +228,7 @@ public class VectorUtil { */ public static float computeDeterminant(float[] a, float[] b, float[] c) { - float area = a[0]*b[1]*c[2] + a[1]*b[2]*c[0] + a[2]*b[0]*c[1] - a[0]*b[2]*c[1] - a[1]*b[0]*c[2] - a[2]*b[1]*c[0]; - return area; + return a[0]*b[1]*c[2] + a[1]*b[2]*c[0] + a[2]*b[0]*c[1] - a[0]*b[2]*c[1] - a[1]*b[0]*c[2] - a[2]*b[1]*c[0]; } /** Check if three vertices are colliniear @@ -255,7 +249,7 @@ public class VectorUtil { */ public static float[] computeVector(float[] v1, float[] v2) { - float[] vector = new float[3]; + final float[] vector = new float[3]; vector[0] = v2[0] - v1[0]; vector[1] = v2[1] - v1[1]; vector[2] = v2[2] - v1[2]; @@ -270,11 +264,11 @@ public class VectorUtil { * @return true if the vertex d is inside the circle defined by the * vertices a, b, c. from paper by Guibas and Stolfi (1985). */ - public static boolean inCircle(Vertex a, Vertex b, Vertex c, Vertex d){ + public static boolean inCircle(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d){ return (a.getX() * a.getX() + a.getY() * a.getY()) * triArea(b, c, d) - - (b.getX() * b.getX() + b.getY() * b.getY()) * triArea(a, c, d) + - (c.getX() * c.getX() + c.getY() * c.getY()) * triArea(a, b, d) - - (d.getX() * d.getX() + d.getY() * d.getY()) * triArea(a, b, c) > 0; + (b.getX() * b.getX() + b.getY() * b.getY()) * triArea(a, c, d) + + (c.getX() * c.getX() + c.getY() * c.getY()) * triArea(a, b, d) - + (d.getX() * d.getX() + d.getY() * d.getY()) * triArea(a, b, c) > 0; } /** Computes oriented area of a triangle @@ -284,7 +278,7 @@ public class VectorUtil { * @return compute twice the area of the oriented triangle (a,b,c), the area * is positive if the triangle is oriented counterclockwise. */ - public static float triArea(Vertex a, Vertex b, Vertex c){ + public static float triArea(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c) { return (b.getX() - a.getX()) * (c.getY() - a.getY()) - (b.getY() - a.getY())*(c.getX() - a.getX()); } @@ -324,7 +318,7 @@ public class VectorUtil { * @param c third vertex * @return true if the points a,b,c are in a ccw order */ - public static boolean ccw(Vertex a, Vertex b, Vertex c){ + public static boolean ccw(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c){ return triArea(a,b,c) > 0; } @@ -334,7 +328,7 @@ public class VectorUtil { * @param c third vertex * @return Winding */ - public static Winding getWinding(Vertex a, Vertex b, Vertex c) { + public static Winding getWinding(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c) { return triArea(a,b,c) > 0 ? Winding.CCW : Winding.CW ; } @@ -342,7 +336,7 @@ public class VectorUtil { * @param vertices * @return positive area if ccw else negative area value */ - public static float area(ArrayList<Vertex> vertices) { + public static float area(ArrayList<? extends Vert2fImmutable> vertices) { int n = vertices.size(); float area = 0.0f; for (int p = n - 1, q = 0; q < n; p = q++) @@ -358,7 +352,7 @@ public class VectorUtil { * @param vertices array of Vertices * @return CCW or CW {@link Winding} */ - public static Winding getWinding(ArrayList<Vertex> vertices) { + public static Winding getWinding(ArrayList<? extends Vert2fImmutable> vertices) { return area(vertices) >= 0 ? Winding.CCW : Winding.CW ; } @@ -371,7 +365,7 @@ public class VectorUtil { * @return the intersection coordinates if the segments intersect, otherwise * returns null */ - public static float[] seg2SegIntersection(Vertex a, Vertex b, Vertex c, Vertex d) { + public static float[] seg2SegIntersection(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d) { float determinant = (a.getX()-b.getX())*(c.getY()-d.getY()) - (a.getY()-b.getY())*(c.getX()-d.getX()); if (determinant == 0) @@ -398,7 +392,7 @@ public class VectorUtil { * @return the intersection coordinates if the lines intersect, otherwise * returns null */ - public static float[] line2lineIntersection(Vertex a, Vertex b, Vertex c, Vertex d) { + public static float[] line2lineIntersection(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d) { float determinant = (a.getX()-b.getX())*(c.getY()-d.getY()) - (a.getY()-b.getY())*(c.getX()-d.getX()); if (determinant == 0) @@ -420,7 +414,7 @@ public class VectorUtil { * @param e vertex 2 of first segment * @return true if the segment intersects at least one segment of the triangle, false otherwise */ - public static boolean tri2SegIntersection(Vertex a, Vertex b, Vertex c, Vertex d, Vertex e){ + public static boolean tri2SegIntersection(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d, Vert2fImmutable e){ if(seg2SegIntersection(a, b, d, e) != null) return true; if(seg2SegIntersection(b, c, d, e) != null) diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vert2fImmutable.java b/src/jogl/classes/com/jogamp/opengl/math/Vert2fImmutable.java new file mode 100644 index 000000000..13349884c --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/math/Vert2fImmutable.java @@ -0,0 +1,39 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.math; + +public interface Vert2fImmutable { + float getX(); + + float getY(); + + int getCoordCount(); + + float[] getCoord(); + +} diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vert3fImmutable.java b/src/jogl/classes/com/jogamp/opengl/math/Vert3fImmutable.java new file mode 100644 index 000000000..76bd02fbc --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/math/Vert3fImmutable.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.math; + +public interface Vert3fImmutable extends Vert2fImmutable { + float getZ(); +} diff --git a/src/jogl/classes/com/jogamp/graph/geom/AABBox.java b/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java index 87f084919..4cd5b31e2 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/AABBox.java +++ b/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java @@ -25,9 +25,10 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package com.jogamp.graph.geom; +package com.jogamp.opengl.math.geom; + +import com.jogamp.opengl.math.VectorUtil; -import com.jogamp.graph.math.VectorUtil; /** * Axis Aligned Bounding Box. Defined by two 3D coordinates (low and high) @@ -291,6 +292,22 @@ public class AABBox implements Cloneable { return low[1]; } + public final float getMinZ() { + return low[2]; + } + + public final float getMaxX() { + return high[0]; + } + + public final float getMaxY() { + return high[1]; + } + + public final float getMaxZ() { + return high[2]; + } + public final float getWidth(){ return high[0] - low[0]; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java index 80df9cd94..34971a9af 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java +++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java @@ -46,9 +46,9 @@ import javax.media.opengl.fixedfunc.GLMatrixFunc; import jogamp.opengl.ProjectFloat; -import com.jogamp.opengl.FloatUtil; import com.jogamp.common.nio.Buffers; import com.jogamp.common.os.Platform; +import com.jogamp.opengl.math.FloatUtil; /** * PMVMatrix implements a subset of the fixed function pipeline diff --git a/src/jogl/classes/javax/media/opengl/GLUniformData.java b/src/jogl/classes/javax/media/opengl/GLUniformData.java index 9638ba8d8..18a422670 100644 --- a/src/jogl/classes/javax/media/opengl/GLUniformData.java +++ b/src/jogl/classes/javax/media/opengl/GLUniformData.java @@ -4,7 +4,7 @@ package javax.media.opengl; import java.nio.*; import com.jogamp.common.nio.Buffers; -import com.jogamp.opengl.FloatUtil; +import com.jogamp.opengl.math.FloatUtil; public class GLUniformData { diff --git a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java index 10b6d6847..e96c559a2 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java @@ -35,7 +35,7 @@ import com.jogamp.graph.curve.tess.Triangulator; import com.jogamp.graph.geom.Outline; import com.jogamp.graph.geom.Triangle; import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.math.VectorUtil; +import com.jogamp.opengl.math.VectorUtil; import jogamp.opengl.Debug; diff --git a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java index b4b796b51..651179062 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java @@ -30,10 +30,10 @@ package jogamp.graph.curve.tess; import java.util.ArrayList; -import com.jogamp.graph.geom.AABBox; import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.Triangle; -import com.jogamp.graph.math.VectorUtil; +import com.jogamp.opengl.math.VectorUtil; +import com.jogamp.opengl.math.geom.AABBox; public class Loop { private HEdge root = null; @@ -250,7 +250,7 @@ public class Loop { continue; } inValid = VectorUtil.inCircle(root.getGraphPoint().getPoint(), next.getGraphPoint().getPoint(), - cand, e.getGraphPoint().getPoint()); + cand, e.getGraphPoint().getPoint()); if(inValid){ break; } diff --git a/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java b/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java index 578148699..751a7e7ac 100644 --- a/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java +++ b/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java @@ -34,7 +34,7 @@ import com.jogamp.graph.geom.Triangle; import com.jogamp.graph.geom.Vertex.Factory; import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.math.Quaternion; +import com.jogamp.opengl.math.Quaternion; public class GlyphShape { diff --git a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java index f86d02f40..cc850b823 100644 --- a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java +++ b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java @@ -30,7 +30,6 @@ package jogamp.graph.curve.text; import java.util.ArrayList; import com.jogamp.graph.font.Font; -import com.jogamp.graph.geom.AABBox; import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.Triangle; import com.jogamp.graph.geom.Vertex.Factory; @@ -45,6 +44,7 @@ import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; +import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.PMVMatrix; public class GlyphString { diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java index 8e465de99..0441bf836 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java @@ -45,9 +45,9 @@ import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.Font.Glyph; -import com.jogamp.graph.geom.AABBox; import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.Vertex.Factory; +import com.jogamp.opengl.math.geom.AABBox; class TypecastFont implements FontInt { static final boolean DEBUG = false; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java index a1f1a3292..1205c6539 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java @@ -34,7 +34,7 @@ import jogamp.graph.geom.plane.AffineTransform; import jogamp.graph.geom.plane.Path2D; import com.jogamp.graph.font.Font; -import com.jogamp.graph.geom.AABBox; +import com.jogamp.opengl.math.geom.AABBox; public class TypecastGlyph implements FontInt.GlyphInt { public class Advance diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java index 0dd7a6178..f170f5819 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java @@ -31,7 +31,7 @@ import jogamp.graph.font.typecast.ot.table.HeadTable; import jogamp.graph.font.typecast.ot.table.HheaTable; import com.jogamp.graph.font.Font.Metrics; -import com.jogamp.graph.geom.AABBox; +import com.jogamp.opengl.math.geom.AABBox; class TypecastHMetrics implements Metrics { private final TypecastFont fontImpl; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java index 5c004246a..244ab400a 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java @@ -56,7 +56,7 @@ import jogamp.graph.font.typecast.ot.table.GlyfDescript; import jogamp.graph.font.typecast.ot.table.GlyphDescription; import jogamp.graph.font.typecast.t2.T2Interpreter; -import com.jogamp.graph.geom.AABBox; +import com.jogamp.opengl.math.geom.AABBox; diff --git a/src/jogl/classes/jogamp/graph/geom/plane/AffineTransform.java b/src/jogl/classes/jogamp/graph/geom/plane/AffineTransform.java index 123883b2f..0fd174cda 100644 --- a/src/jogl/classes/jogamp/graph/geom/plane/AffineTransform.java +++ b/src/jogl/classes/jogamp/graph/geom/plane/AffineTransform.java @@ -26,7 +26,7 @@ import java.io.Serializable; import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.Vertex.Factory; -import com.jogamp.opengl.FloatUtil; +import com.jogamp.opengl.math.FloatUtil; public class AffineTransform implements Cloneable, Serializable { diff --git a/src/jogl/classes/jogamp/graph/math/plane/Crossing.java b/src/jogl/classes/jogamp/graph/geom/plane/Crossing.java index 51d81da54..cd4ee2a91 100644 --- a/src/jogl/classes/jogamp/graph/math/plane/Crossing.java +++ b/src/jogl/classes/jogamp/graph/geom/plane/Crossing.java @@ -17,12 +17,10 @@ /** * @author Denis M. Kishenko */ -package jogamp.graph.math.plane; +package jogamp.graph.geom.plane; -import com.jogamp.opengl.FloatUtil; +import com.jogamp.opengl.math.FloatUtil; -import jogamp.graph.geom.plane.Path2D; -import jogamp.graph.geom.plane.PathIterator; public class Crossing { diff --git a/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java b/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java index c895e8351..945eeceeb 100644 --- a/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java +++ b/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java @@ -21,11 +21,10 @@ package jogamp.graph.geom.plane; import java.util.NoSuchElementException; -import com.jogamp.graph.geom.AABBox; import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.opengl.SVertex; +import com.jogamp.opengl.math.geom.AABBox; -import jogamp.graph.math.plane.Crossing; public final class Path2D implements Cloneable { diff --git a/src/jogl/classes/jogamp/opengl/ProjectFloat.java b/src/jogl/classes/jogamp/opengl/ProjectFloat.java index 18fe3e77e..439ddc76e 100644 --- a/src/jogl/classes/jogamp/opengl/ProjectFloat.java +++ b/src/jogl/classes/jogamp/opengl/ProjectFloat.java @@ -122,7 +122,7 @@ import java.nio.IntBuffer; import javax.media.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.common.nio.Buffers; -import com.jogamp.opengl.FloatUtil; +import com.jogamp.opengl.math.FloatUtil; /** * ProjectFloat.java |