-/*\r
- Copyright (C) 1997,1998,1999\r
- Kenji Hiranabe, Eiwa System Management, Inc.\r
-\r
- This program is free software.\r
- Implemented by Kenji Hiranabe(hiranabe@esm.co.jp),\r
- conforming to the Java(TM) 3D API specification by Sun Microsystems.\r
-\r
- Permission to use, copy, modify, distribute and sell this software\r
- and its documentation for any purpose is hereby granted without fee,\r
- provided that the above copyright notice appear in all copies and\r
- that both that copyright notice and this permission notice appear\r
- in supporting documentation. Kenji Hiranabe and Eiwa System Management,Inc.\r
- makes no representations about the suitability of this software for any\r
- purpose. It is provided "AS IS" with NO WARRANTY.\r
- */\r
-package javajs.util;\r
-\r
-\r
-/**\r
- * A 3-element vector that is represented by single precision floating point\r
- * x,y,z coordinates. If this value represents a normal, then it should be\r
- * normalized.\r
- * \r
- * @version specification 1.1, implementation $Revision: 1.10 $, $Date:\r
- * 2006/10/03 19:52:30 $\r
- * @author Kenji hiranabe\r
- * \r
- * additions by Bob Hanson hansonr@stolaf.edu 9/30/2012\r
- * for unique constructor and method names\r
- * for the optimization of compiled JavaScript using Java2Script\r
- */\r
-public class V3 extends T3 {\r
-\r
- /**\r
- * @j2sIgnoreSuperConstructor\r
- */\r
- public V3() {\r
- // ignore T3\r
- }\r
- public static V3 newV(T3 t) {\r
- return V3.new3(t.x, t.y, t.z);\r
- }\r
-\r
- public static V3 newVsub(T3 t1, T3 t2) {\r
- return V3.new3(t1.x - t2.x, t1.y - t2.y,t1.z - t2.z);\r
- }\r
-\r
- public static V3 new3(float x, float y, float z) {\r
- V3 v = new V3();\r
- v.x = x;\r
- v.y = y;\r
- v.z = z;\r
- return v;\r
- }\r
-\r
- /**\r
- * Returns the angle in radians between this vector and the vector parameter;\r
- * the return value is constrained to the range [0,PI].\r
- * \r
- * @param v1\r
- * the other vector\r
- * @return the angle in radians in the range [0,PI]\r
- */\r
- public final float angle(V3 v1) {\r
- // return (double)Math.acos(dot(v1)/v1.length()/v.length());\r
- // Numerically, near 0 and PI are very bad condition for acos.\r
- // In 3-space, |atan2(sin,cos)| is much stable.\r
-\r
- double xx = y * v1.z - z * v1.y;\r
- double yy = z * v1.x - x * v1.z;\r
- double zz = x * v1.y - y * v1.x;\r
- double cross = Math.sqrt(xx * xx + yy * yy + zz * zz);\r
-\r
- return (float) Math.abs(Math.atan2(cross, dot(v1)));\r
- }\r
-}\r
+/*
+ Copyright (C) 1997,1998,1999
+ Kenji Hiranabe, Eiwa System Management, Inc.
+
+ This program is free software.
+ Implemented by Kenji Hiranabe(hiranabe@esm.co.jp),
+ conforming to the Java(TM) 3D API specification by Sun Microsystems.
+
+ Permission to use, copy, modify, distribute and sell this software
+ and its documentation for any purpose is hereby granted without fee,
+ provided that the above copyright notice appear in all copies and
+ that both that copyright notice and this permission notice appear
+ in supporting documentation. Kenji Hiranabe and Eiwa System Management,Inc.
+ makes no representations about the suitability of this software for any
+ purpose. It is provided "AS IS" with NO WARRANTY.
+ */
+package javajs.util;
+
+
+/**
+ * A 3-element vector that is represented by single precision floating point
+ * x,y,z coordinates. If this value represents a normal, then it should be
+ * normalized.
+ *
+ * @version specification 1.1, implementation $Revision: 1.10 $, $Date:
+ * 2006/10/03 19:52:30 $
+ * @author Kenji hiranabe
+ *
+ * additions by Bob Hanson hansonr@stolaf.edu 9/30/2012
+ * for unique constructor and method names
+ * for the optimization of compiled JavaScript using Java2Script
+ */
+public class V3 extends T3 {
+
+ /**
+ * @j2sIgnoreSuperConstructor
+ */
+ public V3() {
+ // ignore T3
+ }
+ public static V3 newV(T3 t) {
+ return V3.new3(t.x, t.y, t.z);
+ }
+
+ public static V3 newVsub(T3 t1, T3 t2) {
+ return V3.new3(t1.x - t2.x, t1.y - t2.y,t1.z - t2.z);
+ }
+
+ public static V3 new3(float x, float y, float z) {
+ V3 v = new V3();
+ v.x = x;
+ v.y = y;
+ v.z = z;
+ return v;
+ }
+
+ /**
+ * Returns the angle in radians between this vector and the vector parameter;
+ * the return value is constrained to the range [0,PI].
+ *
+ * @param v1
+ * the other vector
+ * @return the angle in radians in the range [0,PI]
+ */
+ public final float angle(V3 v1) {
+ // return (double)Math.acos(dot(v1)/v1.length()/v.length());
+ // Numerically, near 0 and PI are very bad condition for acos.
+ // In 3-space, |atan2(sin,cos)| is much stable.
+
+ double xx = y * v1.z - z * v1.y;
+ double yy = z * v1.x - x * v1.z;
+ double zz = x * v1.y - y * v1.x;
+ double cross = Math.sqrt(xx * xx + yy * yy + zz * zz);
+
+ return (float) Math.abs(Math.atan2(cross, dot(v1)));
+ }
+}