[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Surface.java, 1.124, 1.125 Coordinat
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2006-12-08 13:37:11
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv14599/src/net/sourceforge/bprocessor/model Modified Files: Surface.java CoordinateSystem.java Log Message: The turn direction of edges with respect to a coordinate-system now takes the orientation of the coordinatesystem into account. The sign of the determinant of a coordinatesystem determines the orientation of the coordinatesystem. The reference output of the directions test has been updated to reflect the above changes. Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.124 retrieving revision 1.125 diff -C2 -d -r1.124 -r1.125 *** Surface.java 8 Dec 2006 11:13:27 -0000 1.124 --- Surface.java 8 Dec 2006 13:37:09 -0000 1.125 *************** *** 64,71 **** /** ! * Find the turn direction of the edges ! * @param edges list of Edge ! * @param system CoordinateSystem ! * @return direction (LEFT or RIGHT) */ public static int direction(List edges, CoordinateSystem system) { --- 64,74 ---- /** ! * Returns the turn direction of a list of edges with respect to ! * a given coordinatesystem. LEFT means the edges runs counterclockwise ! * and RIGHT means clockwise when translated to the given coordinate-system. ! * The orientation of the coordinate-system is taken into account. ! * @param edges list of edges whose turn direction are to be calculated ! * @param system the reference coordinatesystem for calculating the turn direction. ! * @return turn direction of the edges with respect to the given coordinate-system */ public static int direction(List edges, CoordinateSystem system) { *************** *** 95,99 **** Vertex v = to.minus(common); Vertex cross = u.cross(v); ! double determinant = cross.getZ(); // if the cross points into the screen (along the negative z), // the vectors are doing a right turn. Otherwise they are doing --- 98,104 ---- Vertex v = to.minus(common); Vertex cross = u.cross(v); ! double determinant = system.determinant(); ! ! // if the cross points into the screen (along the negative z), // the vectors are doing a right turn. Otherwise they are doing *************** *** 101,112 **** // above code should ensure that does not happen assuming the // edges has a nonzero area. ! // Note the direction of the z-axis are not taken into account. ! // The coordinatesystem is treated as right-handed. ! ! if (determinant < 0) { return RIGHT; } ! if (determinant > 0) { return LEFT; } --- 106,117 ---- // above code should ensure that does not happen assuming the // edges has a nonzero area. + // The sign of the determinant of the coordinate-system determines + // the orientation of the coordinate-system: positive means right-handed + // and negative means left-handed. ! if (cross.getZ() * determinant < 0) { return RIGHT; } ! if (cross.getZ() * determinant > 0) { return LEFT; } Index: CoordinateSystem.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/CoordinateSystem.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** CoordinateSystem.java 30 Oct 2006 10:42:17 -0000 1.30 --- CoordinateSystem.java 8 Dec 2006 13:37:09 -0000 1.31 *************** *** 87,90 **** --- 87,103 ---- /** + * Computes the box-product of the vectors of this CoordinateSystem: + * box(i, j, n) = i * (j X n). + * The sign of the box-product determines the orientation: positive + * means right-handed and negative means left-handed. + * Zero means the vectors are linearly dependent in which case they + * do not really define a CoordinateSystem. + * @return the box product of the three vectors defining + * this CoordinateSystem (i * (j X n)) + */ + public double determinant() { + return i.dot(j.cross(n)); + } + /** * normalize vectors */ |