Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv9106/src/net/sourceforge/bprocessor/model
Modified Files:
Edge.java
Log Message:
Improved shift-locking in AbstractPencil
Index: Edge.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** Edge.java 1 May 2006 09:53:39 -0000 1.45
--- Edge.java 20 Jul 2006 13:46:46 -0000 1.46
***************
*** 279,305 ****
*/
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;
! }
}
}
--- 279,293 ----
*/
public Vertex intersection(Vertex vertex) {
if (intersects(vertex)) {
+ Project.info("A-Type");
return vertex;
} else {
! Project.info("B-Type");
! Vertex v = to.minus(from);
! double length = getLength();
! Vertex w = vertex.minus(from);
! double t = v.dot(w);
! v.scale(t / (length * length));
! return from.add(v);
}
}
|