[Bprocessor-commit] test/src/net/sourceforge/bprocessor/test HandedNess.java, NONE, 1.1
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2006-12-08 13:37:10
|
Update of /cvsroot/bprocessor/test/src/net/sourceforge/bprocessor/test In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv14544/src/net/sourceforge/bprocessor/test Added Files: HandedNess.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. --- NEW FILE: HandedNess.java --- //--------------------------------------------------------------------------------- // $Id: HandedNess.java,v 1.1 2006/12/08 13:37:05 henryml Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.test; import java.io.File; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Entity; import net.sourceforge.bprocessor.model.Persistence; import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; /** * */ public class HandedNess { /** * Runs this test on the file named by args[0] * @param args arguments are filename */ public static void main(String[] args) { File input = new File(args[0]); try { Persistence.load(input); test(Project.getInstance().world().getSurfaces()); } catch (Exception e) { e.printStackTrace(); } } private static void test(Collection surfaces) { List sorted = new LinkedList(surfaces); Entity.sort(sorted); Vertex origin = new Vertex(0, 0, 0); Vertex i = new Vertex(1, 0, 0); Vertex j = new Vertex(0, 1, 0); Vertex k = new Vertex(0, 0, 1); System.out.println(" basics:"); System.out.println(" i * j X k = " + box(i, j, k)); System.out.println(" i * j X -k = " + box(i, j, origin.minus(k))); CoordinateSystem xy = new CoordinateSystem(i, j, k, origin); CoordinateSystem yx = new CoordinateSystem(j, i, k, origin); CoordinateSystem xynegz = new CoordinateSystem(i, j, origin.minus(k), origin); CoordinateSystem yz = new CoordinateSystem(j, k, i, origin); CoordinateSystem zx = new CoordinateSystem(k, i, j, origin); print(xy); print(yx); print(xynegz); print(yz); print(zx); print(sorted); } private static double box(Vertex i, Vertex j, Vertex k) { return i.dot(j.cross(k)); } private static double box(CoordinateSystem system) { return system.determinant(); } private static void print(CoordinateSystem system) { System.out.println(" " + system + " box = " + box(system)); } private static void print(List surfaces) { System.out.println(" surfaces own coordinate-systems:"); Iterator iter = surfaces.iterator(); while (iter.hasNext()) { Surface current = (Surface) iter.next(); CoordinateSystem system = current.coordinateSystem(); System.out.println(" " + current.getName() + ": " + system + " box = " + box(system)); } } } |