Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32143/src/net/sourceforge/bprocessor/model
Modified Files:
Surface.java
Log Message:
Implemented Surface.coordinateSystem()
Index: Surface.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** Surface.java 31 Aug 2005 10:30:15 -0000 1.16
--- Surface.java 1 Sep 2005 12:44:01 -0000 1.17
***************
*** 279,282 ****
--- 279,307 ----
/**
+ * Returns a CoordinateSystem where the xy-plane is
+ * co-planar to this Surface
+ * @return The local coordinate system for this Surface
+ */
+ public CoordinateSystem coordinateSystem() {
+ if (edges.size() > 1) {
+ Vertex i, j, n, origin;
+ Edge e0 = (Edge) edges.get(0);
+ Edge e1 = (Edge) edges.get(1);
+ origin = e0.getFrom();
+ Vertex p = e0.getTo();
+ Vertex q = e1.otherVertex(p);
+ i = p.minus(origin);
+ i.scale(1 / i.length());
+ Vertex v = q.minus(p);
+ n = i.cross(v);
+ n.scale(1 / n.length());
+ j = i.cross(n);
+ j.scale(1 / j.length());
+ return new CoordinateSystem(i, j, n, origin);
+ } else {
+ return null;
+ }
+ }
+ /**
* Returns the projection on the surface normal
* @param p The point to project on the normal
|