-/*\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
-import java.io.Serializable;\r
-\r
-/**\r
- * A generic 3 element tuple that is represented by double precision floating\r
- * point x,y and z coordinates.\r
- * \r
- * @version specification 1.1, implementation $Revision: 1.9 $, $Date:\r
- * 2006/07/28 17:01:32 $\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 abstract class T3d implements Serializable {\r
- /**\r
- * The x coordinate.\r
- */\r
- public double x;\r
-\r
- /**\r
- * The y coordinate.\r
- */\r
- public double y;\r
-\r
- /**\r
- * The z coordinate.\r
- */\r
- public double z;\r
-\r
- /**\r
- * Constructs and initializes a Tuple3d to (0,0,0).\r
- */\r
- public T3d() {\r
- }\r
-\r
- /**\r
- * Sets the value of this tuple to the specified xyz coordinates.\r
- * \r
- * @param x\r
- * the x coordinate\r
- * @param y\r
- * the y coordinate\r
- * @param z\r
- * the z coordinate\r
- */\r
- public final void set(double x, double y, double z) {\r
- this.x = x;\r
- this.y = y;\r
- this.z = z;\r
- }\r
-\r
- /**\r
- * Sets the value of this tuple from the 3 values specified in the array.\r
- * \r
- * @param t\r
- * the array of length 3 containing xyz in order\r
- */\r
- public final void setA(double t[]) {\r
- // ArrayIndexOutOfBounds is thrown if t.length < 3\r
- x = t[0];\r
- y = t[1];\r
- z = t[2];\r
- }\r
-\r
- /**\r
- * Sets the value of this tuple to the value of the Tuple3d argument.\r
- * \r
- * @param t1\r
- * the tuple to be copied\r
- */\r
- public final void setT(T3d t1) {\r
- x = t1.x;\r
- y = t1.y;\r
- z = t1.z;\r
- }\r
-\r
- /**\r
- * Sets the value of this tuple to the vector sum of tuples t1 and t2.\r
- * \r
- * @param t1\r
- * the first tuple\r
- * @param t2\r
- * the second tuple\r
- */\r
- public final void add2(T3d t1, T3d t2) {\r
- x = t1.x + t2.x;\r
- y = t1.y + t2.y;\r
- z = t1.z + t2.z;\r
- }\r
-\r
- /**\r
- * Sets the value of this tuple to the vector sum of itself and tuple t1.\r
- * \r
- * @param t1\r
- * the other tuple\r
- */\r
- public final void add(T3d t1) {\r
- x += t1.x;\r
- y += t1.y;\r
- z += t1.z;\r
- }\r
-\r
- /**\r
- * Sets the value of this tuple to the vector difference of tuple t1 and t2\r
- * (this = t1 - t2).\r
- * \r
- * @param t1\r
- * the first tuple\r
- * @param t2\r
- * the second tuple\r
- */\r
- public final void sub2(T3d t1, T3d t2) {\r
- x = t1.x - t2.x;\r
- y = t1.y - t2.y;\r
- z = t1.z - t2.z;\r
- }\r
-\r
- /**\r
- * Sets the value of this tuple to the vector difference of itself and tuple\r
- * t1 (this = this - t1).\r
- * \r
- * @param t1\r
- * the other tuple\r
- */\r
- public final void sub(T3d t1) {\r
- x -= t1.x;\r
- y -= t1.y;\r
- z -= t1.z;\r
- }\r
-\r
- /**\r
- * Sets the value of this tuple to the scalar multiplication of itself.\r
- * \r
- * @param s\r
- * the scalar value\r
- */\r
- public final void scale(double s) {\r
- x *= s;\r
- y *= s;\r
- z *= s;\r
- }\r
-\r
- /**\r
- * Sets the value of this tuple to the scalar multiplication of tuple t1 and\r
- * then adds tuple t2 (this = s*t1 + t2).\r
- * \r
- * @param s\r
- * the scalar value\r
- * @param t1\r
- * the tuple to be multipled\r
- * @param t2\r
- * the tuple to be added\r
- */\r
- public final void scaleAdd(double s, T3d t1, T3d t2) {\r
- x = s * t1.x + t2.x;\r
- y = s * t1.y + t2.y;\r
- z = s * t1.z + t2.z;\r
- }\r
-\r
- /**\r
- * Returns a hash number based on the data values in this object. Two\r
- * different Tuple3d objects with identical data values (ie, returns true for\r
- * equals(Tuple3d) ) will return the same hash number. Two vectors with\r
- * different data members may return the same hash value, although this is not\r
- * likely.\r
- */\r
- @Override\r
- public int hashCode() {\r
- long xbits = doubleToLongBits0(x);\r
- long ybits = doubleToLongBits0(y);\r
- long zbits = doubleToLongBits0(z);\r
- return (int) (xbits ^ (xbits >> 32) ^ ybits ^ (ybits >> 32) ^ zbits ^ (zbits >> 32));\r
- }\r
-\r
- static long doubleToLongBits0(double d) {\r
- // Check for +0 or -0\r
- return (d == 0 ? 0 : Double.doubleToLongBits(d));\r
- }\r
-\r
- /**\r
- * Returns true if all of the data members of Tuple3d t1 are equal to the\r
- * corresponding data members in this\r
- * \r
- * @param t1\r
- * the vector with which the comparison is made.\r
- */\r
- @Override\r
- public boolean equals(Object t1) {\r
- if (!(t1 instanceof T3d))\r
- return false;\r
- T3d t2 = (T3d) t1;\r
- return (this.x == t2.x && this.y == t2.y && this.z == t2.z);\r
- }\r
-\r
- /**\r
- * Returns a string that contains the values of this Tuple3d. The form is\r
- * (x,y,z).\r
- * \r
- * @return the String representation\r
- */\r
- @Override\r
- public String toString() {\r
- return "{" + x + ", " + y + ", " + z + "}";\r
- }\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;
+
+import java.io.Serializable;
+
+/**
+ * A generic 3 element tuple that is represented by double precision floating
+ * point x,y and z coordinates.
+ *
+ * @version specification 1.1, implementation $Revision: 1.9 $, $Date:
+ * 2006/07/28 17:01:32 $
+ * @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 abstract class T3d implements Serializable {
+ /**
+ * The x coordinate.
+ */
+ public double x;
+
+ /**
+ * The y coordinate.
+ */
+ public double y;
+
+ /**
+ * The z coordinate.
+ */
+ public double z;
+
+ /**
+ * Constructs and initializes a Tuple3d to (0,0,0).
+ */
+ public T3d() {
+ }
+
+ /**
+ * Sets the value of this tuple to the specified xyz coordinates.
+ *
+ * @param x
+ * the x coordinate
+ * @param y
+ * the y coordinate
+ * @param z
+ * the z coordinate
+ */
+ public final void set(double x, double y, double z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ /**
+ * Sets the value of this tuple from the 3 values specified in the array.
+ *
+ * @param t
+ * the array of length 3 containing xyz in order
+ */
+ public final void setA(double t[]) {
+ // ArrayIndexOutOfBounds is thrown if t.length < 3
+ x = t[0];
+ y = t[1];
+ z = t[2];
+ }
+
+ /**
+ * Sets the value of this tuple to the value of the Tuple3d argument.
+ *
+ * @param t1
+ * the tuple to be copied
+ */
+ public final void setT(T3d t1) {
+ x = t1.x;
+ y = t1.y;
+ z = t1.z;
+ }
+
+ /**
+ * Sets the value of this tuple to the vector sum of tuples t1 and t2.
+ *
+ * @param t1
+ * the first tuple
+ * @param t2
+ * the second tuple
+ */
+ public final void add2(T3d t1, T3d t2) {
+ x = t1.x + t2.x;
+ y = t1.y + t2.y;
+ z = t1.z + t2.z;
+ }
+
+ /**
+ * Sets the value of this tuple to the vector sum of itself and tuple t1.
+ *
+ * @param t1
+ * the other tuple
+ */
+ public final void add(T3d t1) {
+ x += t1.x;
+ y += t1.y;
+ z += t1.z;
+ }
+
+ /**
+ * Sets the value of this tuple to the vector difference of tuple t1 and t2
+ * (this = t1 - t2).
+ *
+ * @param t1
+ * the first tuple
+ * @param t2
+ * the second tuple
+ */
+ public final void sub2(T3d t1, T3d t2) {
+ x = t1.x - t2.x;
+ y = t1.y - t2.y;
+ z = t1.z - t2.z;
+ }
+
+ /**
+ * Sets the value of this tuple to the vector difference of itself and tuple
+ * t1 (this = this - t1).
+ *
+ * @param t1
+ * the other tuple
+ */
+ public final void sub(T3d t1) {
+ x -= t1.x;
+ y -= t1.y;
+ z -= t1.z;
+ }
+
+ /**
+ * Sets the value of this tuple to the scalar multiplication of itself.
+ *
+ * @param s
+ * the scalar value
+ */
+ public final void scale(double s) {
+ x *= s;
+ y *= s;
+ z *= s;
+ }
+
+ /**
+ * Sets the value of this tuple to the scalar multiplication of tuple t1 and
+ * then adds tuple t2 (this = s*t1 + t2).
+ *
+ * @param s
+ * the scalar value
+ * @param t1
+ * the tuple to be multipled
+ * @param t2
+ * the tuple to be added
+ */
+ public final void scaleAdd(double s, T3d t1, T3d t2) {
+ x = s * t1.x + t2.x;
+ y = s * t1.y + t2.y;
+ z = s * t1.z + t2.z;
+ }
+
+ /**
+ * Returns a hash number based on the data values in this object. Two
+ * different Tuple3d objects with identical data values (ie, returns true for
+ * equals(Tuple3d) ) will return the same hash number. Two vectors with
+ * different data members may return the same hash value, although this is not
+ * likely.
+ */
+ @Override
+ public int hashCode() {
+ long xbits = doubleToLongBits0(x);
+ long ybits = doubleToLongBits0(y);
+ long zbits = doubleToLongBits0(z);
+ return (int) (xbits ^ (xbits >> 32) ^ ybits ^ (ybits >> 32) ^ zbits ^ (zbits >> 32));
+ }
+
+ static long doubleToLongBits0(double d) {
+ // Check for +0 or -0
+ return (d == 0 ? 0 : Double.doubleToLongBits(d));
+ }
+
+ /**
+ * Returns true if all of the data members of Tuple3d t1 are equal to the
+ * corresponding data members in this
+ *
+ * @param t1
+ * the vector with which the comparison is made.
+ */
+ @Override
+ public boolean equals(Object t1) {
+ if (!(t1 instanceof T3d))
+ return false;
+ T3d t2 = (T3d) t1;
+ return (this.x == t2.x && this.y == t2.y && this.z == t2.z);
+ }
+
+ /**
+ * Returns a string that contains the values of this Tuple3d. The form is
+ * (x,y,z).
+ *
+ * @return the String representation
+ */
+ @Override
+ public String toString() {
+ return "{" + x + ", " + y + ", " + z + "}";
+ }
+
+}