[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Plane.java,1.18,1.19 CoordinateSystem
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2006-05-05 14:08:48
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28956/src/net/sourceforge/bprocessor/model Modified Files: Plane.java CoordinateSystem.java Log Message: Plane.coordinateSystem() implemented Orthogonal Constructor implemented in first version that only works with xy plane Index: CoordinateSystem.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/CoordinateSystem.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CoordinateSystem.java 22 Mar 2006 10:53:18 -0000 1.9 --- CoordinateSystem.java 5 May 2006 14:08:42 -0000 1.10 *************** *** 117,120 **** --- 117,128 ---- /** + * Set the origin + * @param origin The new origin + */ + public void setOrigin(Vertex origin) { + this.origin = origin; + } + + /** * Return the xy plane of this CoordinateSystem * @return The xy plane *************** *** 219,221 **** --- 227,236 ---- } + /** + * @return String + */ + public String toString() { + return "[i = " + i + " j = " + j + " n = " + n + " o = " + origin + "]"; + } + } Index: Plane.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Plane.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Plane.java 21 Apr 2006 15:21:59 -0000 1.18 --- Plane.java 5 May 2006 14:08:42 -0000 1.19 *************** *** 255,258 **** --- 255,290 ---- /** + * A CoordinateSystem is returned for this plane. + * @return CoordinateSystem + */ + public CoordinateSystem coordinateSystem() { + Vertex origin = origin(); + Vertex n = new Vertex(a, b, c); + int index = largestCoefficient(); + Vertex i = null; + Vertex j = null; + + if (index == X) { + i = new Vertex(0, 1, 0); + } + if (index == Y) { + i = new Vertex(0, 0, 1); + } + if (index == Z) { + i = new Vertex(1, 0, 0); + } + + double t = n.dot(i); + i.setX(i.getX() - n.getX() * t); + i.setY(i.getY() - n.getY() * t); + i.setZ(i.getZ() - n.getZ() * t); + i.scale(1 / i.length()); + + j = n.cross(i); + + return new CoordinateSystem(i, j, n, origin); + } + + /** * Project a vector into this plane * @param vector The vector to project |