Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26586/src/net/sourceforge/bprocessor/model
Modified Files:
Edge.java
Log Message:
Improvemenents of construction line functionality in pencil
Index: Edge.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** Edge.java 25 Mar 2006 18:08:32 -0000 1.42
--- Edge.java 29 Mar 2006 13:18:35 -0000 1.43
***************
*** 271,274 ****
--- 271,309 ----
/**
+ * Finds the intersection between a Vertex and this
+ * edge. The intersection is defined as the vertex
+ * on this edge with the smalled perpendicular distance
+ * to the vertex
+ * @param vertex The vertex
+ * @return The intersection
+ */
+ public Vertex intersection(Vertex vertex) {
+ //FIXME the following seems too longwinded
+ // There has got to be a better way!
+ if (intersects(vertex)) {
+ return vertex;
+ } else {
+ Edge edge = new Edge(getFrom(), vertex);
+ CoordinateSystem system = CoordinateSystem.create(this, edge);
+ if (system != null) {
+ Vertex a = system.translate(getFrom());
+ Vertex b = system.translate(getTo());
+ Vertex p = system.translate(vertex);
+
+ Vertex u = b.minus(a);
+ u.scale(1 / u.length());
+ Vertex ap = p.minus(a);
+ double t = u.dot(ap);
+ u.scale(t);
+ Vertex q = a.add(u);
+ q = system.unTranslate(q);
+ return q;
+ } else {
+ return vertex;
+ }
+ }
+ }
+
+ /**
* Split this edge and update all surfaces
* accordingly.
|