Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5456/src/net/sourceforge/bprocessor/model
Modified Files:
Edge.java Surface.java
Log Message:
Edge.intersection(Edge) implemented
Plane.intersection(Edge) made public
Index: Surface.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** Surface.java 31 Aug 2005 08:33:17 -0000 1.15
--- Surface.java 31 Aug 2005 10:30:15 -0000 1.16
***************
*** 264,268 ****
*/
! Plane plane() {
double d = 0;
Vertex n = normal();
--- 264,268 ----
*/
! public Plane plane() {
double d = 0;
Vertex n = normal();
Index: Edge.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Edge.java 31 Aug 2005 08:33:17 -0000 1.7
--- Edge.java 31 Aug 2005 10:30:15 -0000 1.8
***************
*** 176,179 ****
--- 176,244 ----
return this.id.equals(e.getId());
}
+
+ /**
+ * Find the intersection between this Edge and the Other.
+ * The intersection is considered to be the shortest Edge
+ * connecting this Edge and the other Edge.
+ * @param other The other edge to intersect with
+ * @return The shortes Edge connecting this Edge and the other
+ */
+ public Edge intersection(Edge other) {
+
+ Vertex p1 = this.getFrom();
+ Vertex p2 = this.getTo();
+ Vertex p3 = other.getFrom();
+ Vertex p4 = other.getTo();
+
+ Vertex pa = new Vertex("pa");
+ Vertex pb = new Vertex("pb");
+
+ Vertex p13 = new Vertex("p13");
+ Vertex p43 = new Vertex("p43");
+ Vertex p21 = new Vertex("p21");
+ double d1343, d4321, d1321, d4343, d2121;
+ double numer, denom;
+ double mua, mub;
+ double eps = 0.0000000001;
+ p13.setX(p1.getX() - p3.getX());
+ p13.setY(p1.getY() - p3.getY());
+ p13.setZ(p1.getZ() - p3.getZ());
+ p43.setX(p4.getX() - p3.getX());
+ p43.setY(p4.getY() - p3.getY());
+ p43.setZ(p4.getZ() - p3.getZ());
+ if (Math.abs(p43.getX()) < eps && Math.abs(p43.getY()) < eps && Math.abs(p43.getZ()) < eps) {
+ return null;
+ }
+ p21.setX(p2.getX() - p1.getX());
+ p21.setY(p2.getY() - p1.getY());
+ p21.setZ(p2.getZ() - p1.getZ());
+ if (Math.abs(p21.getX()) < eps && Math.abs(p21.getY()) < eps && Math.abs(p21.getZ()) < eps) {
+ return null;
+ }
+
+ d1343 = p13.getX() * p43.getX() + p13.getY() * p43.getY() + p13.getZ() * p43.getZ();
+ d4321 = p43.getX() * p21.getX() + p43.getY() * p21.getY() + p43.getZ() * p21.getZ();
+ d1321 = p13.getX() * p21.getX() + p13.getY() * p21.getY() + p13.getZ() * p21.getZ();
+ d4343 = p43.getX() * p43.getX() + p43.getY() * p43.getY() + p43.getZ() * p43.getZ();
+ d2121 = p21.getX() * p21.getX() + p21.getY() * p21.getY() + p21.getZ() * p21.getZ();
+
+ denom = d2121 * d4343 - d4321 * d4321;
+ if (Math.abs(denom) < eps) {
+ return null;
+ }
+ numer = d1343 * d4321 - d1321 * d4343;
+
+ mua = numer / denom;
+ mub = (d1343 + d4321 * (mua)) / d4343;
+
+ pa.setX(p1.getX() + mua * p21.getX());
+ pa.setY(p1.getY() + mua * p21.getY());
+ pa.setZ(p1.getZ() + mua * p21.getZ());
+ pb.setX(p3.getX() + mub * p43.getX());
+ pb.setY(p3.getY() + mub * p43.getY());
+ pb.setZ(p3.getZ() + mub * p43.getZ());
+
+ return new Edge("intersection", pa, pb);
+ }
/**
|