[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Vertex.java,1.8,1.9 Surface.java,1.26
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2005-09-22 14:11:03
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1642/src/net/sourceforge/bprocessor/model Modified Files: Vertex.java Surface.java CoordinateSystem.java Log Message: Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Surface.java 21 Sep 2005 14:04:33 -0000 1.26 --- Surface.java 22 Sep 2005 14:10:47 -0000 1.27 *************** *** 224,227 **** --- 224,253 ---- return null; } + + /** + * Calculate center of gravity + * @return The center of gravity + */ + public Vertex center() { + List vertices = this.getVertices(); + if (vertices.size() > 0) { + double x = 0; + double y = 0; + double z = 0; + Iterator iter = vertices.iterator(); + while (iter.hasNext()) { + Vertex current = (Vertex) iter.next(); + x += current.getX(); + y += current.getY(); + z += current.getZ(); + } + x = x / (double) vertices.size(); + y = y / (double) vertices.size(); + z = z / (double) vertices.size(); + return new Vertex("center of " + getName(), x, y, z); + } else { + return null; + } + } /** * Get the inner surfaces Index: Vertex.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Vertex.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Vertex.java 8 Sep 2005 10:42:14 -0000 1.8 --- Vertex.java 22 Sep 2005 14:10:47 -0000 1.9 *************** *** 210,213 **** --- 210,226 ---- return res; } + + /** + * Computes the addition of this Vertex and the given vertex + * @param v The vertex to add to this Vertex + * @return The addition + */ + public Vertex add(Vertex v) { + Vertex res = new Vertex("add"); + res.setX(this.getX() + v.getX()); + res.setY(this.getY() + v.getY()); + res.setZ(this.getZ() + v.getZ()); + return res; + } /** Index: CoordinateSystem.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/CoordinateSystem.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CoordinateSystem.java 1 Sep 2005 12:17:16 -0000 1.1 --- CoordinateSystem.java 22 Sep 2005 14:10:47 -0000 1.2 *************** *** 45,48 **** --- 45,73 ---- this.origin = origin; } + + /** + * Return the i vector + * @return The i vector + */ + public Vertex getI() { + return i; + } + + /** + * Return the j vector + * @return The j vector + */ + public Vertex getJ() { + return j; + } + + /** + * Return the n vector + * @return The n vector + */ + public Vertex getN() { + return n; + } + /** |