Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv2180/src/net/sourceforge/bprocessor/model
Modified Files:
Geometry.java Line.java
Log Message:
refactored degree functions to Geometry and changed methods in Line to calls to Geometry instead
Index: Geometry.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Geometry.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** Geometry.java 7 Jun 2006 08:22:37 -0000 1.20
--- Geometry.java 12 Jul 2006 14:30:36 -0000 1.21
***************
*** 705,707 ****
--- 705,744 ----
}
}
+
+
+ /**
+ * Calculate the rotation of a direction vector about the z-axis
+ * @param dir The direction vector
+ * @return Returns the degrees in radian about the z-axis.
+ */
+ public static double degreesAboutZ(Vertex dir) {
+ Vertex tmp;
+ if (dir.getX() != 0.0) {
+ tmp = new Vertex(dir.getX(), dir.getY(), 0);
+ } else {
+ tmp = new Vertex(0, dir.getY(), dir.getZ());
+ }
+ tmp.normalize();
+ if (dir.getY() < 0) {
+ return -Math.acos(tmp.getX());
+ } else {
+ return Math.acos(tmp.getX());
+ }
+ }
+
+ /**
+ * Calculate the rotation of a direction vector about the y-axis
+ * @param dir The direction vector
+ * @return Returns the degrees in radian about the y-axis.
+ */
+ public static double degreesAboutY(Vertex dir) {
+ Vertex tmp;
+ if (dir.getX() != 0.0) {
+ tmp = new Vertex(dir.getX(), 0, dir.getZ());
+ } else {
+ tmp = new Vertex(0, dir.getY(), dir.getZ());
+ }
+ tmp.normalize();
+ return Math.asin(tmp.getZ());
+ }
}
Index: Line.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Line.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Line.java 12 Jul 2006 13:25:02 -0000 1.7
--- Line.java 12 Jul 2006 14:30:36 -0000 1.8
***************
*** 82,117 ****
/**
- * @return Returns the degrees in radian about the z-axis.
- */
- public double degreesAboutZ() {
- Vertex tmp;
- if (dir.getX() != 0.0) {
- tmp = new Vertex(dir.getX(), dir.getY(), 0);
- } else {
- tmp = new Vertex(0, dir.getY(), dir.getZ());
- }
- tmp.normalize();
- if (dir.getY() < 0) {
- return -Math.acos(tmp.getX());
- } else {
- return Math.acos(tmp.getX());
- }
- }
-
- /**
- * @return Returns the degrees in radian about the y-axis.
- */
- public double degreesAboutY() {
- Vertex tmp;
- if (dir.getX() != 0.0) {
- tmp = new Vertex(dir.getX(), 0, dir.getZ());
- } else {
- tmp = new Vertex(0, dir.getY(), dir.getZ());
- }
- tmp.normalize();
- return Math.asin(tmp.getZ());
- }
-
- /**
* @see net.sourceforge.bprocessor.model.Parametric#setAttributes()
*/
--- 82,85 ----
***************
*** 146,148 ****
--- 114,130 ----
return "[Line: " + getOrigin() + " direction: " + getDirection() + "]";
}
+
+ /**
+ * @see @see net.sourceforge.bprocessor.model.Geometry#degreesAboutY(Vertex)
+ */
+ public double degreesAboutY() {
+ return Geometry.degreesAboutY(dir);
+ }
+
+ /**
+ * @see @see net.sourceforge.bprocessor.model.Geometry#degreesAboutZ(Vertex)
+ */
+ public double degreesAboutZ() {
+ return Geometry.degreesAboutZ(dir);
+ }
}
|