Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31121/src/net/sourceforge/bprocessor/model
Modified Files:
Vertex.java
Log Message:
changed implementation of some math operations on vertex
Index: Vertex.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Vertex.java,v
retrieving revision 1.69
retrieving revision 1.70
diff -C2 -d -r1.69 -r1.70
*** Vertex.java 13 Nov 2007 12:21:49 -0000 1.69
--- Vertex.java 13 Nov 2007 12:40:19 -0000 1.70
***************
*** 213,223 ****
/**
* Return a scaled copy of this Vertex
! * @param scale the amout to scale the copy
* @return a scaled copy
*/
! public Vertex scale(double scale) {
! Vertex v = this.copy();
! v.scaleInPlace(scale);
! return v;
}
--- 213,221 ----
/**
* Return a scaled copy of this Vertex
! * @param t the amout to scale the copy
* @return a scaled copy
*/
! public Vertex scale(double t) {
! return new Vertex(x * t, y * t, z * t);
}
***************
*** 247,255 ****
*/
public Vertex minus(Vertex v) {
! Vertex res = new Vertex();
! res.setX(this.getX() - v.getX());
! res.setY(this.getY() - v.getY());
! res.setZ(this.getZ() - v.getZ());
! return res;
}
--- 245,249 ----
*/
public Vertex minus(Vertex v) {
! return new Vertex(x - v.x, y - v.y, z - v.z);
}
***************
*** 260,268 ****
*/
public Vertex add(Vertex v) {
! Vertex res = new Vertex();
! res.setX(this.getX() + v.getX());
! res.setY(this.getY() + v.getY());
! res.setZ(this.getZ() + v.getZ());
! return res;
}
--- 254,258 ----
*/
public Vertex add(Vertex v) {
! return new Vertex(x + v.x, y + v.y, z + v.z);
}
***************
*** 274,280 ****
public Vertex cross(Vertex v) {
Vertex cross = new Vertex();
! 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;
}
--- 264,270 ----
public Vertex cross(Vertex v) {
Vertex cross = new Vertex();
! cross.x = y * v.z - v.y * z;
! cross.y = z * v.x - v.z * x;
! cross.z = x * v.y - v.x * y;
return cross;
}
***************
*** 295,299 ****
*/
public double angle(Vertex v) {
! return Math.acos(this.dot(v) / (this.length() * v.length()));
}
--- 285,289 ----
*/
public double angle(Vertex v) {
! return Math.acos(dot(v) / (length() * v.length()));
}
***************
*** 303,307 ****
*/
public double length() {
! return Math.sqrt(getX() * getX() + getY() * getY() + getZ() * getZ());
}
--- 293,297 ----
*/
public double length() {
! return Math.sqrt(x * x + y * y + z * z);
}
***************
*** 312,353 ****
*/
public double distance(Vertex v) {
! double dx = v.getX() - getX();
! double dy = v.getY() - getY();
! double dz = v.getZ() - getZ();
return Math.sqrt(dx * dx + dy * dy + dz * dz);
}
/**
- * Computes the the determinant of this and to other vertecies.
- * The form is: determinant{this, v, u}.
- * @param v the second vertex
- * @param u the third vertex
- * @return the determinant.
- */
- public double determinant(Vertex v, Vertex u) {
- double tx = this.getX();
- double ty = this.getY();
- double tz = this.getZ();
-
- double vx = v.getX();
- double vy = v.getY();
- double vz = v.getZ();
-
- double ux = u.getX();
- double uy = u.getY();
- double uz = u.getZ();
-
- double result = tx * ((vy * uz) - (vz * uy));
- result -= vx * ((ty * uz) - (tz * uy));
- result += ux * ((ty * vz) - (tz * vy));
- return result;
- }
-
- /**
* Is this a zero vector?
* @return True if this is a zero vector
*/
public boolean isZero() {
! return (length() < 0.0000001);
}
--- 302,317 ----
*/
public double distance(Vertex v) {
! double dx = v.x - x;
! double dy = v.y - y;
! double dz = v.z - z;
return Math.sqrt(dx * dx + dy * dy + dz * dz);
}
/**
* Is this a zero vector?
* @return True if this is a zero vector
*/
public boolean isZero() {
! return (length() < 0.0000001);
}
|