diff options
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java b/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java index 0033afeaa..508f1aafd 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java @@ -39,7 +39,7 @@ public class VectorUtil { Winding(int dir) { this.dir = dir; } - } + } public static final int COLLINEAR = 0; @@ -119,15 +119,15 @@ public class VectorUtil { /** Column Matrix Vector multiplication * @param colMatrix column matrix (4x4) * @param vec vector(x,y,z) - * @return result new float[3] + * @return result new float[3] */ public static float[] colMatrixVectorMult(float[] colMatrix, float[] vec) { 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]; - out[2] = vec[0]*colMatrix[2] + vec[1]*colMatrix[6] + vec[2]*colMatrix[10] + colMatrix[14]; + 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]; + out[2] = vec[0]*colMatrix[2] + vec[1]*colMatrix[6] + vec[2]*colMatrix[10] + colMatrix[14]; return out; } @@ -135,15 +135,15 @@ public class VectorUtil { /** Matrix Vector multiplication * @param rawMatrix column matrix (4x4) * @param vec vector(x,y,z) - * @return result new float[3] + * @return result new float[3] */ public static float[] rowMatrixVectorMult(float[] rawMatrix, float[] vec) { 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]; - out[2] = vec[0]*rawMatrix[8] + vec[1]*rawMatrix[9] + vec[2]*rawMatrix[10] + rawMatrix[11]; + 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]; + out[2] = vec[0]*rawMatrix[8] + vec[1]*rawMatrix[9] + vec[2]*rawMatrix[10] + rawMatrix[11]; return out; } @@ -157,7 +157,7 @@ public class VectorUtil { { return (p1+p2)/2.0f; } - + /** Calculate the midpoint of two points * @param p1 first point * @param p2 second point @@ -172,7 +172,7 @@ public class VectorUtil { return midPoint; } - + /** Compute the norm of a vector * @param vec vector * @return vorm @@ -181,7 +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 @@ -216,7 +216,7 @@ public class VectorUtil { */ public static boolean checkEqualityVec2(float[] v1, float[] v2) { - return Float.compare(v1[0], v2[0]) == 0 && + return Float.compare(v1[0], v2[0]) == 0 && Float.compare(v1[1], v2[1]) == 0 ; } @@ -261,7 +261,7 @@ public class VectorUtil { * @param b triangle vertex 2 * @param c triangle vertex 3 * @param d vertex in question - * @return true if the vertex d is inside the circle defined by the + * @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(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d){ @@ -282,8 +282,8 @@ public class VectorUtil { return (b.getX() - a.getX()) * (c.getY() - a.getY()) - (b.getY() - a.getY())*(c.getX() - a.getX()); } - /** Check if a vertex is in triangle using - * barycentric coordinates computation. + /** Check if a vertex is in triangle using + * barycentric coordinates computation. * @param a first triangle vertex * @param b second triangle vertex * @param c third triangle vertex @@ -291,7 +291,7 @@ public class VectorUtil { * @return true if p is in triangle (a, b, c), false otherwise. */ public static boolean vertexInTriangle(float[] a, float[] b, float[] c, float[] p){ - // Compute vectors + // Compute vectors final float[] ac = computeVector(a, c); //v0 final float[] ab = computeVector(a, b); //v1 final float[] ap = computeVector(a, p); //v2 @@ -362,13 +362,13 @@ public class VectorUtil { * @param b vertex 2 of first segment * @param c vertex 1 of second segment * @param d vertex 2 of second segment - * @return the intersection coordinates if the segments intersect, otherwise - * returns null + * @return the intersection coordinates if the segments intersect, otherwise + * returns null */ public static float[] seg2SegIntersection(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d) { final float determinant = (a.getX()-b.getX())*(c.getY()-d.getY()) - (a.getY()-b.getY())*(c.getX()-d.getX()); - if (determinant == 0) + if (determinant == 0) return null; final float alpha = (a.getX()*b.getY()-a.getY()*b.getX()); @@ -389,13 +389,13 @@ public class VectorUtil { * @param b vertex 2 of first line * @param c vertex 1 of second line * @param d vertex 2 of second line - * @return the intersection coordinates if the lines intersect, otherwise - * returns null + * @return the intersection coordinates if the lines intersect, otherwise + * returns null */ public static float[] line2lineIntersection(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d) { final float determinant = (a.getX()-b.getX())*(c.getY()-d.getY()) - (a.getY()-b.getY())*(c.getX()-d.getX()); - if (determinant == 0) + if (determinant == 0) return null; final float alpha = (a.getX()*b.getY()-a.getY()*b.getX()); |