[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Vertex.java,1.3,1.4
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2005-08-05 10:41:14
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27231/model Modified Files: Vertex.java Log Message: Added methods for dot and corss products Index: Vertex.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Vertex.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Vertex.java 28 Jul 2005 06:48:54 -0000 1.3 --- Vertex.java 5 Aug 2005 10:40:58 -0000 1.4 *************** *** 8,11 **** --- 8,12 ---- import java.io.Serializable; + import java.util.Set; import org.apache.log4j.Logger; *************** *** 163,166 **** --- 164,228 ---- /** + * returns the edges connected to this vertex + * @return The connected vertexes + */ + public Set getEdges() { + return EdgeFacade.getInstance().findByVertex(this); + } + + /** + * scales the vertex by the the given double + * @param scale The scale + */ + public void scale(double scale) { + setX(getX() * scale); + setY(getY() * scale); + setZ(getZ() * scale); + } + + /** + * Method that computes this - the give vertex + * @param v The Vertex to minus with + * @return the difference between this and v + */ + public Vertex minus(Vertex v) { + Vertex res = new Vertex("minus"); + res.setX(this.getX() - v.getX()); + res.setY(this.getY() - v.getY()); + res.setZ(this.getZ() - v.getZ()); + return res; + } + + /** + * Computates the cross product with this and the given vertex + * @param v The Vertex to cross with + * @return The Crossproduct + */ + public Vertex cross(Vertex v) { + Vertex cross = new Vertex("cross"); + cross.setX(this.getY() * v.getZ() - v.getY() * this.getZ()); + cross.setY(this.getZ() * v.getX() - v.getZ() * this.getX()); + cross.setZ(this.getX() * v.getY() - v.getX() * this.getY()); + return cross; + } + + /** + * Computates the dot product with this and the given vertex + * @param v The Vertex to dot product with + * @return The dot product + */ + public double dot(Vertex v) { + return this.getX() * v.getX() + this.getY() * v.getY() + this.getZ() * v.getZ(); + } + + /** + * compute the lengt of the vertex + * @return the length of the vertex + */ + public double length() { + return Math.sqrt(Math.abs(getX() * getX() + getY() * getY() + getZ() * getZ())); + } + + /** * Return the hash code of the object * @return The hash |