diff options
author | Alessandro Borges <[email protected]> | 2007-11-14 01:52:18 +0000 |
---|---|---|
committer | Alessandro Borges <[email protected]> | 2007-11-14 01:52:18 +0000 |
commit | b392b3a0bdc2ae1e510fe064e40f399f4a558c73 (patch) | |
tree | 9b8515acc2025cd4a3e64cbbadc6ea517965c265 /src | |
parent | 50e86dcc01cca6a7c5c2dc9a135e4ab7f70a1f09 (diff) |
Issue #541 Bound.closest_point() method creates unused Matrix3d
Line was moved from line 251 to line 446
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@872 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src')
-rw-r--r-- | src/classes/share/javax/media/j3d/Bounds.java | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/src/classes/share/javax/media/j3d/Bounds.java b/src/classes/share/javax/media/j3d/Bounds.java index b2d38c5..cf57038 100644 --- a/src/classes/share/javax/media/j3d/Bounds.java +++ b/src/classes/share/javax/media/j3d/Bounds.java @@ -41,7 +41,7 @@ public abstract class Bounds extends Object implements Cloneable { /** - * Makes a copy of a bounds object. + * Makes a copy of a bounds object. */ public abstract Object clone(); @@ -95,7 +95,7 @@ public abstract class Bounds extends Object implements Cloneable { * Test for intersection with a ray * @param origin is a the starting point of the ray * @param direction is the direction of the ray - * @param position is a point defining the location of the pick w= distance to pick + * @param position is a point defining the location of the pick w= distance to pick * @return true or false indicating if an intersection occured */ abstract boolean intersect( Point3d origin, Vector3d direction, Point4d position ); @@ -103,20 +103,20 @@ public abstract class Bounds extends Object implements Cloneable { /** * Test for intersection with a point * @param point is a point defining a position in 3-space - * @param position is a point defining the location of the pick w= distance to pick + * @param position is a point defining the location of the pick w= distance to pick * @return true or false indicating if an intersection occured */ abstract boolean intersect( Point3d point, Point4d position); /** * Test for intersection with a segment - * @param start is a point defining the start of the line segment - * @param end is a point defining the end of the line segment - * @param position is a point defining the location of the pick w= distance to pick + * @param start is a point defining the start of the line segment + * @param end is a point defining the end of the line segment + * @param position is a point defining the location of the pick w= distance to pick * @return true or false indicating if an intersection occured */ abstract boolean intersect( Point3d start, Point3d end, Point4d position ); - + /** * Test for intersection with another bounds object * @@ -124,14 +124,14 @@ public abstract class Bounds extends Object implements Cloneable { * @param boundsObject is another bounds object * @return true or false indicating if an intersection occured */ - abstract boolean intersect( Bounds boundsObject, Point4d position ); + abstract boolean intersect( Bounds boundsObject, Point4d position ); /** * Test for intersection with another bounds object. * @param boundsObject another bounds object * @return true or false indicating if an intersection occurred */ - public abstract boolean intersect( Bounds boundsObject ); + public abstract boolean intersect( Bounds boundsObject ); /** * Test for intersection with another bounds object. @@ -140,35 +140,35 @@ public abstract class Bounds extends Object implements Cloneable { */ public abstract boolean intersect( Bounds[] boundsObjects ); - + /** * Finds closest bounding object that intersects this bounding object. * @param boundsObjects an array of bounds objects * @return closest bounding object - */ - public abstract Bounds closestIntersection( Bounds[] boundsObjects); + */ + public abstract Bounds closestIntersection( Bounds[] boundsObjects); /** - * Returns the center of the bounds - * @return bounds center - */ - abstract Point3d getCenter(); + * Returns the center of the bounds + * @return bounds center + */ + abstract Point3d getCenter(); /** * Combines this bounding object with a bounding object so that the * resulting bounding object encloses the original bounding object and the * given bounds object. * @param boundsObject another bounds object - */ + */ public abstract void combine( Bounds boundsObject ); - /** + /** * Combines this bounding object with an array of bounding objects so that the * resulting bounding object encloses the original bounding object and the * given array of bounds object. * @param boundsObjects an array of bounds objects - */ + */ public abstract void combine( Bounds[] boundsObjects); /** @@ -194,7 +194,7 @@ public abstract class Bounds extends Object implements Cloneable { * generated by transforming the given bounding object. * @param bounds the bounding object to be transformed * @param trans the transformation matrix - */ + */ public abstract void transform( Bounds bounds, Transform3D trans); /** @@ -208,7 +208,7 @@ public abstract class Bounds extends Object implements Cloneable { /** * Sets the value of this Bounds object. - * @param boundsObject another bounds object. + * @param boundsObject another bounds object. */ public abstract void set( Bounds boundsObject); @@ -228,9 +228,9 @@ public abstract class Bounds extends Object implements Cloneable { } /** - * computes the closest point from the given point to a set of planes + * computes the closest point from the given point to a set of planes * (polytope) - * @param g the point + * @param g the point * @param planes array of bounding planes * @param new_point point on planes closest g */ @@ -248,21 +248,21 @@ public abstract class Bounds extends Object implements Cloneable { Vector3d delta = null; // These are temporary until the solve code is working - Matrix3d hMatrix = new Matrix3d(); + /* * The algorithm: * We want to find the point "n", closest to "g", while still within * the the polytope defined by "planes". We find the solution by * minimizing the value for a "penalty function"; - * + * * f = distance(n,g)^2 + sum for each i: w(distance(n, planes[i])) - * + * * Where "w" is a weighting which indicates how much more important * it is to be close to the planes than it is to be close to "g". * * We minimize this function by taking it's derivitive, and then - * solving for the value of n when the derivitive equals 0. + * solving for the value of n when the derivitive equals 0. * * For the 1D case with a single plane (a,b,c,d), x = n.x and g = g.x, * this looks like: @@ -279,20 +279,20 @@ public abstract class Bounds extends Object implements Cloneable { * outside the planes. * * Extending to 3D gives the matrix solution: - * + * * | (1 + waa) wab wac | * H = | wab (1 + wbb) wbc | * | wac wbc (1 + wcc) | * * b = [g.x - wad, g.y - wbd, g.z - wcd] - * + * * H * n = b - * + * * n = b * H.inverse() * * The implementation speeds this process up by recognizing that * H is symmetric, so that it can be decomposed into three matrices: - * + * * H = L * D * L.transpose() * * 1.0 0.0 0.0 d1 0.0 0.0 @@ -305,7 +305,7 @@ public abstract class Bounds extends Object implements Cloneable { * H * n = b * L * D * L.transpose() * n = b * L * D * y = b; L.transpose() * n = y - * + * * We can then multiply out the terms of L * D and solve for y, and * then use y to solve for n. */ @@ -336,16 +336,16 @@ public abstract class Bounds extends Object implements Cloneable { // plane that is violated, add it's contribution to the // penalty function inside = true; - aa=0.0; bb=0.0; cc=0.0; + aa=0.0; bb=0.0; cc=0.0; ab=0.0; ac=0.0; bc=0.0; ad=0.0; bd=0.0; cd=0.0; for(i = 0; i < planes.length; i++){ pln = planes[i]; dist = (p.x*pln.x + p.y*pln.y + p.z*pln.z + pln.w ) ; - // if point is outside or within EPSILON of the boundary, add - // the plane to the penalty matrix. We do this even if the - // point is already inside the polytope to prevent numerical - // instablity in cases where the point is just outside the + // if point is outside or within EPSILON of the boundary, add + // the plane to the penalty matrix. We do this even if the + // point is already inside the polytope to prevent numerical + // instablity in cases where the point is just outside the // boundary of several planes of the polytope if (dist > -EPSILON ){ aa = aa + pln.x * pln.x; @@ -358,7 +358,7 @@ public abstract class Bounds extends Object implements Cloneable { bd = bd + pln.y * pln.w; cd = cd + pln.z * pln.w; } - // If the point is inside if dist is <= EPSILON + // If the point is inside if dist is <= EPSILON if (dist > EPSILON ){ inside = false; if (debug) { @@ -375,7 +375,7 @@ public abstract class Bounds extends Object implements Cloneable { } if (firstPoint) { firstInside = true; - } + } new_point.set(p); converged = true; } else { // solve for a closer point @@ -436,7 +436,7 @@ public abstract class Bounds extends Object implements Cloneable { n.x = (y1 - l13*n.z - l12*n.y); if (debug) { - System.err.println("new point = " + n.x+" " + n.y+" " + + System.err.println("new point = " + n.x+" " + n.y+" " + n.z); test_point(planes, n); @@ -444,7 +444,7 @@ public abstract class Bounds extends Object implements Cloneable { delta.sub(n, p); delta.normalize(); System.err.println("p->n direction: " + delta); - + Matrix3d hMatrix = new Matrix3d(); // check using the the javax.vecmath routine hMatrix.m00 = h11; hMatrix.m01 = h12; @@ -459,12 +459,12 @@ public abstract class Bounds extends Object implements Cloneable { Point3d check = new Point3d(b1, b2, b3); hMatrix.transform(check); - System.err.println("check point = " + check.x+" " + + System.err.println("check point = " + check.x+" " + check.y+" " + check.z); } // see if we have converged yet - dist = (p.x-n.x)*(p.x-n.x) + (p.y-n.y)*(p.y-n.y) + + dist = (p.x-n.x)*(p.x-n.x) + (p.y-n.y)*(p.y-n.y) + (p.z-n.z)*(p.z-n.z); if (debug) { @@ -493,7 +493,7 @@ public abstract class Bounds extends Object implements Cloneable { return firstInside; } - boolean intersect_ptope_sphere( BoundingPolytope polyTope, + boolean intersect_ptope_sphere( BoundingPolytope polyTope, BoundingSphere sphere) { Point3d p = new Point3d(); boolean inside; @@ -507,9 +507,9 @@ public abstract class Bounds extends Object implements Cloneable { System.err.println("ptope sphere intersect point ="+p); } if (!inside){ - // if distance between polytope and sphere center is greater than + // if distance between polytope and sphere center is greater than // radius then no intersection - if (p.distanceSquared( sphere.center) > + if (p.distanceSquared( sphere.center) > sphere.radius*sphere.radius){ if (debug) { System.err.println("ptope_sphere returns false"); @@ -544,16 +544,16 @@ public abstract class Bounds extends Object implements Cloneable { BoundingPolytope pbox = new BoundingPolytope( planes); - + boolean result = intersect_ptope_ptope( polyTope, pbox ); if (debug) { System.err.println("ptope_abox returns " + result); } return(result); - } + } - boolean intersect_ptope_ptope( BoundingPolytope poly1, + boolean intersect_ptope_ptope( BoundingPolytope poly1, BoundingPolytope poly2) { boolean intersect; Point3d p = new Point3d(); @@ -569,10 +569,10 @@ public abstract class Bounds extends Object implements Cloneable { // start from an arbitrary point on poly1 closest_point( p, poly1.planes, g); - + // get the closest points on each polytope if (debug) { - System.err.println("ptope_ptope: first g = "+g); + System.err.println("ptope_ptope: first g = "+g); } intersect = closest_point( g, poly2.planes, p); @@ -581,11 +581,11 @@ public abstract class Bounds extends Object implements Cloneable { } if (debug) { - System.err.println("first p = "+p+"\n"); + System.err.println("first p = "+p+"\n"); } intersect = closest_point( p, poly1.planes, gnew); if (debug) { - System.err.println("gnew = "+gnew+" intersect="+intersect); + System.err.println("gnew = "+gnew+" intersect="+intersect); } // loop until the closest points on the two polytopes are not changing @@ -601,7 +601,7 @@ public abstract class Bounds extends Object implements Cloneable { g.set(gnew); intersect = closest_point( g, poly2.planes, pnew ); if (debug) { - System.err.println("pnew = "+pnew+" intersect="+intersect); + System.err.println("pnew = "+pnew+" intersect="+intersect); } } else { g.set(gnew); @@ -612,11 +612,11 @@ public abstract class Bounds extends Object implements Cloneable { if (dist < prevDist) { p.set(pnew); - if( !intersect ) { + if( !intersect ) { intersect = closest_point( p, poly1.planes, gnew ); if (debug) { System.err.println("gnew = "+gnew+" intersect="+ - intersect); + intersect); } } } else { |