[Bprocessor-commit] /model/src/net/sourceforge/bprocessor/model CoordinateSystem.java, 1.67, 1.68
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2007-12-10 08:34:29
|
Update of /cvsroot/bprocessor//model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29525/src/net/sourceforge/bprocessor/model Modified Files: CoordinateSystem.java Log Message: Finally instancemove works Index: CoordinateSystem.java =================================================================== RCS file: /cvsroot/bprocessor//model/src/net/sourceforge/bprocessor/model/CoordinateSystem.java,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** CoordinateSystem.java 3 Dec 2007 17:52:59 -0000 1.67 --- CoordinateSystem.java 10 Dec 2007 08:34:21 -0000 1.68 *************** *** 592,595 **** --- 592,662 ---- /** + * Translate one coordinatesystem into this + * @param coordinate The coordinatesystem to translate + * @return The translated coordinatesystem + */ + public CoordinateSystem translate(CoordinateSystem coordinate) { + Vertex newI = coordinate.i; + double x = i.dot(newI); + double y = j.dot(newI); + double z = n.dot(newI); + newI.setX(x); + newI.setY(y); + newI.setZ(z); + Vertex newJ = coordinate.j; + x = i.dot(newJ); + y = j.dot(newJ); + z = n.dot(newJ); + newJ.setX(x); + newJ.setY(y); + newJ.setZ(z); + Vertex newN = coordinate.n; + x = i.dot(newN); + y = j.dot(newN); + z = n.dot(newN); + newN.setX(x); + newN.setY(y); + newN.setZ(z); + Vertex origin = translate(coordinate.origin); + return new CoordinateSystem(newI, newJ, newN, origin); + } + + /** + * Untranslate the given coordinatesystem out of this + * @param coordinate The coordinatesystem to untranslate + * @return The untranslated coordinatesystem + */ + public CoordinateSystem unTranslate(CoordinateSystem coordinate) { + Vertex ii = i.copy(); + Vertex jj = j.copy(); + Vertex nn = n.copy(); + Vertex newI = coordinate.i; + ii.scaleInPlace(newI.getX()); + jj.scaleInPlace(newI.getY()); + nn.scaleInPlace(newI.getZ()); + newI = ii.add(jj).add(nn); + + ii = i.copy(); + jj = j.copy(); + nn = n.copy(); + Vertex newJ = coordinate.j; + ii.scaleInPlace(newJ.getX()); + jj.scaleInPlace(newJ.getY()); + nn.scaleInPlace(newJ.getZ()); + newJ = ii.add(jj).add(nn); + + ii = i.copy(); + jj = j.copy(); + nn = n.copy(); + Vertex newN = coordinate.n; + ii.scaleInPlace(newN.getX()); + jj.scaleInPlace(newN.getY()); + nn.scaleInPlace(newN.getZ()); + newN = ii.add(jj).add(nn); + Vertex origin = unTranslate(coordinate.origin); + return new CoordinateSystem(newI, newJ, newN, origin); + } + + /** * @return String */ |