diff options
37 files changed, 680 insertions, 55 deletions
diff --git a/LICENSE.txt b/LICENSE.txt index 930cc77..e2d1c2f 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -2,8 +2,12 @@ This software is licensed by Sun: i) for research use under terms of the Java Research License (JRL) as specified in the LICENSE-JRL.txt file and on the web at -"http://java3d.dev.java.net/jrl.html"; or +"http://java3d.dev.java.net/jrl.html" -ii) for commercial use under the terms of the Java Distribution License -(JDL) as specified in the LICENSE-JDL.txt file and on the web at -"http://java3d.dev.java.net/jdl-java3d.pdf". +NOTE: The main trunk of the vecmath source code (vecmath +project) contains proposed API changes for an eventual 1.4 version of +the Java 3D API. THESE API CHANGES ARE NOT YET APPROVED AS PART OF +A JAVA SPECIFICATION REQUEST (JSR) UNDER THE JAVA COMMUNITY PROCESS +(JCP). UNTIL SUCH TIME AS THEY ARE ADOPTED AND APPROVED BY A JSR, +THE 1.4-EXPERIMENTAL VERSION OF THE JAVA 3D API MAY ONLY BE USED FOR +RESEARCH UNDER THE TERMS OF THE JAVA RESEARCH LICENSE (JRL). diff --git a/README-FIRST.txt b/README-FIRST.txt index e84c25b..2b46b5b 100644 --- a/README-FIRST.txt +++ b/README-FIRST.txt @@ -1,3 +1,11 @@ +NOTE: The main trunk of the vecmath source code (vecmath +project) contains proposed API changes for an eventual 1.4 version of +the Java 3D API. THESE API CHANGES ARE NOT YET APPROVED AS PART OF +A JAVA SPECIFICATION REQUEST (JSR) UNDER THE JAVA COMMUNITY PROCESS +(JCP). UNTIL SUCH TIME AS THEY ARE ADOPTED AND APPROVED BY A JSR, +THE 1.4-EXPERIMENTAL VERSION OF THE JAVA 3D API MAY ONLY BE USED FOR +RESEARCH UNDER THE TERMS OF THE JAVA RESEARCH LICENSE (JRL). + The source code for the vecmath project is copyrighted code that is licensed to individuals or companies who download or otherwise access the code. @@ -14,13 +14,13 @@ */ --> -<project name="vecmath" default="jar-opt" basedir="."> +<project name="vecmath-1.4.0" default="jar-opt" basedir="."> <!-- Set global properties for this build --> <property name="src" location="src"/> <property name="build" location="build"/> <property name="dist" location="dist"/> - <property name="version" value="1_3_2"/> + <property name="version" value="1_4_0"/> <property name="docname" value="vecmath-${version}-doc"/> <target name="echo"> diff --git a/docs/api-changes-1_4.txt b/docs/api-changes-1_4.txt new file mode 100644 index 0000000..e7fee87 --- /dev/null +++ b/docs/api-changes-1_4.txt @@ -0,0 +1,46 @@ +------------------------------------------------------------------------ +$RCSfile$ +$Revision$ +$Date$ +------------------------------------------------------------------------ +This document conatains proposed API changes to the vecmath 1.4 API +that deviate from the 1.3 API. + +This file must be updated to record the addition or deprecation of any +public or protected class, interface, field, constructor, or method to +the vecmath API. + +The one exception to this rule is that you don't need to update this +file when adding a non-final (i.e., virtual) method to a class if that +method--with exactly the same signature--already exists in a +superclass. For example, adding a "toString" method to a vecmath object +doesn't require an entry in this file. + +No incompatible changes to the vecmath 1.3 API are allowed. + + +I. New/deprecated fields, constructors, methods + + <EXISTINGCLASS> + --------------- + New methods: + <NEWMETHOD> + + +II. Reparented classes + + <EXISTINGCLASS> + --------------- + <EXISTINGCLASS> now extends <NEWSUPERCLASS> (used to extend <OLDSUPERCLASS>) + + +III. New classes and interfaces (in javax.vecmath) + + Tuple2i + ------- + public abstract class Tuple2i implements Serializable, Cloneable + + Point2i + ------- + public class Point2i extends Tuple2i + diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..9bd60e9 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://www.netbeans.org/ns/project/1"> + <type>org.netbeans.modules.ant.freeform</type> + <configuration> + <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1"> + <!--Do not use Project Properties customizer when editing this file manually.--> + <name>vecmath-1.4.0</name> + <properties/> + <folders> + <source-folder> + <label>src</label> + <type>java</type> + <location>src</location> + </source-folder> + </folders> + <ide-actions> + <action name="build"> + <target>jar-debug</target> + </action> + <action name="clean"> + <target>clean</target> + </action> + <action name="javadoc"> + <target>docs</target> + </action> + <action name="rebuild"> + <target>clean</target> + <target>jar-debug</target> + </action> + </ide-actions> + <export> + <type>jar</type> + <location>build/debug/lib/ext/vecmath.jar</location> + <build-target>jar-debug</build-target> + </export> + <view> + <items> + <source-folder style="packages"> + <label>src</label> + <location>src</location> + </source-folder> + <source-file> + <location>build.xml</location> + </source-file> + </items> + <context-menu> + <ide-action name="build"/> + <ide-action name="clean"/> + <ide-action name="javadoc"/> + <ide-action name="rebuild"/> + </context-menu> + </view> + <subprojects/> + </general-data> + <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1"> + <compilation-unit> + <package-root>src</package-root> + <built-to>build/debug/lib/ext/vecmath.jar</built-to> + <source-level>1.4</source-level> + </compilation-unit> + </java-data> + </configuration> +</project> diff --git a/src/VECMATH.MF b/src/VECMATH.MF index 32b4dad..feef661 100644 --- a/src/VECMATH.MF +++ b/src/VECMATH.MF @@ -1,9 +1,9 @@ Manifest-Version: 1.0 Specification-Title: Java 3D API Specification -Specification-Version: 1.3 +Specification-Version: 1.4 Specification-Vendor: Sun Microsystems, Inc. Implementation-Title: Java 3D Vecmath Runtime Environment -Implementation-Version: 1.3.2 +Implementation-Version: 1.4.0 Implementation-Vendor: Sun Microsystems, Inc. Extension-Name: javax.vecmath Implementation-Vendor-Id: com.sun diff --git a/src/javax/vecmath/AxisAngle4d.java b/src/javax/vecmath/AxisAngle4d.java index a72e7f0..7dbd59c 100644 --- a/src/javax/vecmath/AxisAngle4d.java +++ b/src/javax/vecmath/AxisAngle4d.java @@ -110,7 +110,7 @@ public class AxisAngle4d implements java.io.Serializable, Cloneable { * @param axis the axis * @param angle the angle of rotation in radian * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public AxisAngle4d(Vector3d axis, double angle) { this.x = axis.x; @@ -193,7 +193,7 @@ public class AxisAngle4d implements java.io.Serializable, Cloneable { * @param axis the axis * @param angle the angle of rotation in radians * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public final void set(Vector3d axis, double angle) { this.x = axis.x; @@ -521,7 +521,7 @@ public class AxisAngle4d implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { // Since there are no arrays we can just use Object.clone() diff --git a/src/javax/vecmath/AxisAngle4f.java b/src/javax/vecmath/AxisAngle4f.java index 6cb625e..ec3b7da 100644 --- a/src/javax/vecmath/AxisAngle4f.java +++ b/src/javax/vecmath/AxisAngle4f.java @@ -109,7 +109,7 @@ public class AxisAngle4f implements java.io.Serializable, Cloneable { * @param axis the axis * @param angle the angle of rotation in radians * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public AxisAngle4f(Vector3f axis, float angle) { this.x = axis.x; @@ -193,7 +193,7 @@ public class AxisAngle4f implements java.io.Serializable, Cloneable { * @param axis the axis * @param angle the angle of rotation in radians * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public final void set(Vector3f axis, float angle) { this.x = axis.x; @@ -517,7 +517,7 @@ public class AxisAngle4f implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { // Since there are no arrays we can just use Object.clone() diff --git a/src/javax/vecmath/Color3b.java b/src/javax/vecmath/Color3b.java index ec9e136..7d465ec 100644 --- a/src/javax/vecmath/Color3b.java +++ b/src/javax/vecmath/Color3b.java @@ -82,7 +82,7 @@ public class Color3b extends Tuple3b implements java.io.Serializable { * @param color the AWT color with which to initialize this * Color3b object * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public Color3b(Color color) { super((byte)color.getRed(), @@ -107,7 +107,7 @@ public class Color3b extends Tuple3b implements java.io.Serializable { * * @param color the AWT color to copy into this Color3b object * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public final void set(Color color) { x = (byte)color.getRed(); @@ -122,7 +122,7 @@ public class Color3b extends Tuple3b implements java.io.Serializable { * * @return a new AWT Color object * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public final Color get() { int r = (int)x & 0xff; diff --git a/src/javax/vecmath/Color3f.java b/src/javax/vecmath/Color3f.java index b2578ab..76736e9 100644 --- a/src/javax/vecmath/Color3f.java +++ b/src/javax/vecmath/Color3f.java @@ -86,7 +86,7 @@ public class Color3f extends Tuple3f implements java.io.Serializable { * @param color the AWT color with which to initialize this * Color3f object * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public Color3f(Color color) { super((float)color.getRed() / 255.0f, @@ -111,7 +111,7 @@ public class Color3f extends Tuple3f implements java.io.Serializable { * * @param color the AWT color to copy into this Color3f object * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public final void set(Color color) { x = (float)color.getRed() / 255.0f; @@ -126,7 +126,7 @@ public class Color3f extends Tuple3f implements java.io.Serializable { * * @return a new AWT Color object * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public final Color get() { int r = Math.round(x * 255.0f); diff --git a/src/javax/vecmath/Color4b.java b/src/javax/vecmath/Color4b.java index f824648..42d6843 100644 --- a/src/javax/vecmath/Color4b.java +++ b/src/javax/vecmath/Color4b.java @@ -85,7 +85,7 @@ public class Color4b extends Tuple4b implements java.io.Serializable { * @param color the AWT color with which to initialize this * Color4b object * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public Color4b(Color color) { super((byte)color.getRed(), @@ -111,7 +111,7 @@ public class Color4b extends Tuple4b implements java.io.Serializable { * * @param color the AWT color to copy into this Color4b object * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public final void set(Color color) { x = (byte)color.getRed(); @@ -127,7 +127,7 @@ public class Color4b extends Tuple4b implements java.io.Serializable { * * @return a new AWT Color object * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public final Color get() { int r = (int)x & 0xff; diff --git a/src/javax/vecmath/Color4f.java b/src/javax/vecmath/Color4f.java index 8cbace1..0d2f5c4 100644 --- a/src/javax/vecmath/Color4f.java +++ b/src/javax/vecmath/Color4f.java @@ -88,7 +88,7 @@ public class Color4f extends Tuple4f implements java.io.Serializable { * @param color the AWT color with which to initialize this * Color4f object * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public Color4f(Color color) { super((float)color.getRed() / 255.0f, @@ -114,7 +114,7 @@ public class Color4f extends Tuple4f implements java.io.Serializable { * * @param color the AWT color to copy into this Color4f object * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public final void set(Color color) { x = (float)color.getRed() / 255.0f; @@ -130,7 +130,7 @@ public class Color4f extends Tuple4f implements java.io.Serializable { * * @return a new AWT Color object * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public final Color get() { int r = Math.round(x * 255.0f); diff --git a/src/javax/vecmath/GMatrix.java b/src/javax/vecmath/GMatrix.java index 7744dcc..21f277f 100644 --- a/src/javax/vecmath/GMatrix.java +++ b/src/javax/vecmath/GMatrix.java @@ -2964,7 +2964,7 @@ public class GMatrix implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { GMatrix m1 = null; diff --git a/src/javax/vecmath/GVector.java b/src/javax/vecmath/GVector.java index 4718ae8..2b57ffc 100644 --- a/src/javax/vecmath/GVector.java +++ b/src/javax/vecmath/GVector.java @@ -891,7 +891,7 @@ public class GVector implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { GVector v1 = null; diff --git a/src/javax/vecmath/Matrix3d.java b/src/javax/vecmath/Matrix3d.java index 7804ef9..2a02b44 100644 --- a/src/javax/vecmath/Matrix3d.java +++ b/src/javax/vecmath/Matrix3d.java @@ -3088,7 +3088,7 @@ static double max3( double[] values) { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { Matrix3d m1 = null; diff --git a/src/javax/vecmath/Matrix3f.java b/src/javax/vecmath/Matrix3f.java index 17ec205..5ccd6c5 100644 --- a/src/javax/vecmath/Matrix3f.java +++ b/src/javax/vecmath/Matrix3f.java @@ -2080,7 +2080,7 @@ public class Matrix3f implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { Matrix3f m1 = null; diff --git a/src/javax/vecmath/Matrix4d.java b/src/javax/vecmath/Matrix4d.java index 62f62f8..6a7bd31 100644 --- a/src/javax/vecmath/Matrix4d.java +++ b/src/javax/vecmath/Matrix4d.java @@ -3568,7 +3568,7 @@ public class Matrix4d implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { Matrix4d m1 = null; diff --git a/src/javax/vecmath/Matrix4f.java b/src/javax/vecmath/Matrix4f.java index 9de5849..9c9d843 100644 --- a/src/javax/vecmath/Matrix4f.java +++ b/src/javax/vecmath/Matrix4f.java @@ -3228,7 +3228,7 @@ public class Matrix4f implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { Matrix4f m1 = null; diff --git a/src/javax/vecmath/Point2i.java b/src/javax/vecmath/Point2i.java new file mode 100644 index 0000000..945e6a9 --- /dev/null +++ b/src/javax/vecmath/Point2i.java @@ -0,0 +1,64 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.vecmath; + +import java.lang.Math; + +/** + * A 2-element point represented by signed integer x,y + * coordinates. + * + * @since vecmath 1.4 + */ +public class Point2i extends Tuple2i implements java.io.Serializable { + + static final long serialVersionUID = 9208072376494084954L; + + /** + * Constructs and initializes a Point2i from the specified + * x and y coordinates. + * @param x the x coordinate + * @param y the y coordinate + */ + public Point2i(int x, int y) { + super(x, y); + } + + + /** + * Constructs and initializes a Point2i from the array of length 2. + * @param t the array of length 2 containing x and y in order. + */ + public Point2i(int[] t) { + super(t); + } + + + /** + * Constructs and initializes a Point2i from the specified Tuple2i. + * @param t1 the Tuple2i containing the initialization x and y + * data. + */ + public Point2i(Tuple2i t1) { + super(t1); + } + + + /** + * Constructs and initializes a Point2i to (0,0). + */ + public Point2i() { + super(); + } + +} diff --git a/src/javax/vecmath/Point3i.java b/src/javax/vecmath/Point3i.java index 66fbf73..cc229a0 100644 --- a/src/javax/vecmath/Point3i.java +++ b/src/javax/vecmath/Point3i.java @@ -18,7 +18,7 @@ import java.lang.Math; * A 3 element point represented by signed integer x,y,z * coordinates. * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public class Point3i extends Tuple3i implements java.io.Serializable { diff --git a/src/javax/vecmath/Point4d.java b/src/javax/vecmath/Point4d.java index 1b8e667..2983e4b 100644 --- a/src/javax/vecmath/Point4d.java +++ b/src/javax/vecmath/Point4d.java @@ -95,7 +95,7 @@ public class Point4d extends Tuple4d implements java.io.Serializable { * is set to 1. * @param t1 the tuple to be copied * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public Point4d(Tuple3d t1) { super(t1.x, t1.y, t1.z, 1.0); @@ -117,7 +117,7 @@ public class Point4d extends Tuple4d implements java.io.Serializable { * is set to 1. * @param t1 the tuple to be copied * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public final void set(Tuple3d t1) { this.x = t1.x; diff --git a/src/javax/vecmath/Point4f.java b/src/javax/vecmath/Point4f.java index 7d6f193..f990886 100644 --- a/src/javax/vecmath/Point4f.java +++ b/src/javax/vecmath/Point4f.java @@ -95,7 +95,7 @@ public class Point4f extends Tuple4f implements java.io.Serializable { * is set to 1. * @param t1 the tuple to be copied * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public Point4f(Tuple3f t1) { super(t1.x, t1.y, t1.z, 1.0f); @@ -117,7 +117,7 @@ public class Point4f extends Tuple4f implements java.io.Serializable { * is set to 1. * @param t1 the tuple to be copied * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public final void set(Tuple3f t1) { this.x = t1.x; diff --git a/src/javax/vecmath/Point4i.java b/src/javax/vecmath/Point4i.java index 80ecb12..d5e6dac 100644 --- a/src/javax/vecmath/Point4i.java +++ b/src/javax/vecmath/Point4i.java @@ -18,7 +18,7 @@ import java.lang.Math; * A 4 element point represented by signed integer x,y,z,w * coordinates. * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public class Point4i extends Tuple4i implements java.io.Serializable { diff --git a/src/javax/vecmath/TexCoord4f.java b/src/javax/vecmath/TexCoord4f.java index 763140d..bc3b2a3 100644 --- a/src/javax/vecmath/TexCoord4f.java +++ b/src/javax/vecmath/TexCoord4f.java @@ -18,7 +18,7 @@ import java.lang.Math; * A 4 element texture coordinate that is represented by single precision * floating point x,y,z,w coordinates. * - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public class TexCoord4f extends Tuple4f implements java.io.Serializable { diff --git a/src/javax/vecmath/Tuple2d.java b/src/javax/vecmath/Tuple2d.java index 3c018e4..efff339 100644 --- a/src/javax/vecmath/Tuple2d.java +++ b/src/javax/vecmath/Tuple2d.java @@ -522,7 +522,7 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { // Since there are no arrays we can just use Object.clone() diff --git a/src/javax/vecmath/Tuple2f.java b/src/javax/vecmath/Tuple2f.java index 45db4ae..5e55637 100644 --- a/src/javax/vecmath/Tuple2f.java +++ b/src/javax/vecmath/Tuple2f.java @@ -526,7 +526,7 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { // Since there are no arrays we can just use Object.clone() diff --git a/src/javax/vecmath/Tuple2i.java b/src/javax/vecmath/Tuple2i.java new file mode 100644 index 0000000..e1a1d18 --- /dev/null +++ b/src/javax/vecmath/Tuple2i.java @@ -0,0 +1,440 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.vecmath; + +import java.lang.Math; + +/** + * A 2-element tuple represented by signed integer x,y + * coordinates. + * + * @since vecmath 1.4 + */ +public abstract class Tuple2i implements java.io.Serializable, Cloneable { + + static final long serialVersionUID = -3555701650170169638L; + + /** + * The x coordinate. + */ + public int x; + + /** + * The y coordinate. + */ + public int y; + + + /** + * Constructs and initializes a Tuple2i from the specified + * x and y coordinates. + * @param x the x coordinate + * @param y the y coordinate + */ + public Tuple2i(int x, int y) { + this.x = x; + this.y = y; + } + + + /** + * Constructs and initializes a Tuple2i from the array of length 2. + * @param t the array of length 2 containing x and y in order. + */ + public Tuple2i(int[] t) { + this.x = t[0]; + this.y = t[1]; + } + + + /** + * Constructs and initializes a Tuple2i from the specified Tuple2i. + * @param t1 the Tuple2i containing the initialization x and y + * data. + */ + public Tuple2i(Tuple2i t1) { + this.x = t1.x; + this.y = t1.y; + } + + + /** + * Constructs and initializes a Tuple2i to (0,0). + */ + public Tuple2i() { + this.x = 0; + this.y = 0; + } + + + /** + * Sets the value of this tuple to the specified x and y + * coordinates. + * @param x the x coordinate + * @param y the y coordinate + */ + public final void set(int x, int y) { + this.x = x; + this.y = y; + } + + + /** + * Sets the value of this tuple to the specified coordinates in the + * array of length 2. + * @param t the array of length 2 containing x and y in order. + */ + public final void set(int[] t) { + this.x = t[0]; + this.y = t[1]; + } + + + /** + * Sets the value of this tuple to the value of tuple t1. + * @param t1 the tuple to be copied + */ + public final void set(Tuple2i t1) { + this.x = t1.x; + this.y = t1.y; + } + + + /** + * Copies the values of this tuple into the array t. + * @param t is the array + */ + public final void get(int[] t) { + t[0] = this.x; + t[1] = this.y; + } + + + /** + * Copies the values of this tuple into the tuple t. + * @param t is the target tuple + */ + public final void get(Tuple2i t) { + t.x = this.x; + t.y = this.y; + } + + + /** + * Sets the value of this tuple to the sum of tuples t1 and t2. + * @param t1 the first tuple + * @param t2 the second tuple + */ + public final void add(Tuple2i t1, Tuple2i t2) { + this.x = t1.x + t2.x; + this.y = t1.y + t2.y; + } + + + /** + * Sets the value of this tuple to the sum of itself and t1. + * @param t1 the other tuple + */ + public final void add(Tuple2i t1) { + this.x += t1.x; + this.y += t1.y; + } + + + /** + * Sets the value of this tuple to the difference + * of tuples t1 and t2 (this = t1 - t2). + * @param t1 the first tuple + * @param t2 the second tuple + */ + public final void sub(Tuple2i t1, Tuple2i t2) { + this.x = t1.x - t2.x; + this.y = t1.y - t2.y; + } + + + /** + * Sets the value of this tuple to the difference + * of itself and t1 (this = this - t1). + * @param t1 the other tuple + */ + public final void sub(Tuple2i t1) { + this.x -= t1.x; + this.y -= t1.y; + } + + + /** + * Sets the value of this tuple to the negation of tuple t1. + * @param t1 the source tuple + */ + public final void negate(Tuple2i t1) { + this.x = -t1.x; + this.y = -t1.y; + } + + + /** + * Negates the value of this tuple in place. + */ + public final void negate() { + this.x = -this.x; + this.y = -this.y; + } + + + /** + * Sets the value of this tuple to the scalar multiplication + * of tuple t1. + * @param s the scalar value + * @param t1 the source tuple + */ + public final void scale(int s, Tuple2i t1) { + this.x = s*t1.x; + this.y = s*t1.y; + } + + + /** + * Sets the value of this tuple to the scalar multiplication + * of the scale factor with this. + * @param s the scalar value + */ + public final void scale(int s) { + this.x *= s; + this.y *= s; + } + + + /** + * Sets the value of this tuple to the scalar multiplication + * of tuple t1 plus 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(int s, Tuple2i t1, Tuple2i t2) { + this.x = s*t1.x + t2.x; + this.y = s*t1.y + t2.y; + } + + + /** + * Sets the value of this tuple to the scalar multiplication + * of itself and then adds tuple t1 (this = s*this + t1). + * @param s the scalar value + * @param t1 the tuple to be added + */ + public final void scaleAdd(int s, Tuple2i t1) { + this.x = s*this.x + t1.x; + this.y = s*this.y + t1.y; + } + + + /** + * Returns a string that contains the values of this Tuple2i. + * The form is (x,y). + * @return the String representation + */ + public String toString() { + return "(" + this.x + ", " + this.y + ")"; + } + + + /** + * Returns true if the Object t1 is of type Tuple2i and all of the + * data members of t1 are equal to the corresponding data members in + * this Tuple2i. + * @param t1 the object with which the comparison is made + */ + public boolean equals(Object t1) { + try { + Tuple2i t2 = (Tuple2i) t1; + return(this.x == t2.x && this.y == t2.y); + } + catch (NullPointerException e2) { + return false; + } + catch (ClassCastException e1) { + return false; + } + } + + + /** + * Returns a hash code value based on the data values in this + * object. Two different Tuple2i objects with identical data values + * (i.e., Tuple2i.equals returns true) will return the same hash + * code value. Two objects with different data members may return the + * same hash value, although this is not likely. + * @return the integer hash code value + */ + public int hashCode() { + long bits = 1L; + bits = 31L * bits + (long)x; + bits = 31L * bits + (long)y; + return (int) (bits ^ (bits >> 32)); + } + + + /** + * Clamps the tuple parameter to the range [low, high] and + * places the values into this tuple. + * @param min the lowest value in the tuple after clamping + * @param max the highest value in the tuple after clamping + * @param t the source tuple, which will not be modified + */ + public final void clamp(int min, int max, Tuple2i t) { + if( t.x > max ) { + x = max; + } else if( t.x < min ) { + x = min; + } else { + x = t.x; + } + + if( t.y > max ) { + y = max; + } else if( t.y < min ) { + y = min; + } else { + y = t.y; + } + } + + + /** + * Clamps the minimum value of the tuple parameter to the min + * parameter and places the values into this tuple. + * @param min the lowest value in the tuple after clamping + * @param t the source tuple, which will not be modified + */ + public final void clampMin(int min, Tuple2i t) { + if( t.x < min ) { + x = min; + } else { + x = t.x; + } + + if( t.y < min ) { + y = min; + } else { + y = t.y; + } + } + + + /** + * Clamps the maximum value of the tuple parameter to the max + * parameter and places the values into this tuple. + * @param max the highest value in the tuple after clamping + * @param t the source tuple, which will not be modified + */ + public final void clampMax(int max, Tuple2i t) { + if( t.x > max ) { + x = max; + } else { + x = t.x; + } + + if( t.y > max ) { + y = max; + } else { + y = t.y; + } + } + + + /** + * Sets each component of the tuple parameter to its absolute + * value and places the modified values into this tuple. + * @param t the source tuple, which will not be modified + */ + public final void absolute(Tuple2i t) { + x = Math.abs(t.x); + y = Math.abs(t.y); + } + + + /** + * Clamps this tuple to the range [low, high]. + * @param min the lowest value in this tuple after clamping + * @param max the highest value in this tuple after clamping + */ + public final void clamp(int min, int max) { + if( x > max ) { + x = max; + } else if( x < min ) { + x = min; + } + + if( y > max ) { + y = max; + } else if( y < min ) { + y = min; + } + } + + + /** + * Clamps the minimum value of this tuple to the min parameter. + * @param min the lowest value in this tuple after clamping + */ + public final void clampMin(int min) { + if (x < min) + x=min; + + if (y < min) + y = min; + } + + + /** + * Clamps the maximum value of this tuple to the max parameter. + * @param max the highest value in the tuple after clamping + */ + public final void clampMax(int max) { + if (x > max) + x = max; + + if (y > max) + y = max; + } + + + /** + * Sets each component of this tuple to its absolute value. + */ + public final void absolute() { + x = Math.abs(x); + y = Math.abs(y); + } + + /** + * Creates a new object of the same class as this object. + * + * @return a clone of this instance. + * @exception OutOfMemoryError if there is not enough memory. + * @see java.lang.Cloneable + */ + public Object clone() { + // Since there are no arrays we can just use Object.clone() + try { + return super.clone(); + } catch (CloneNotSupportedException e) { + // this shouldn't happen, since we are Cloneable + throw new InternalError(); + } + } + +} diff --git a/src/javax/vecmath/Tuple3b.java b/src/javax/vecmath/Tuple3b.java index 0d4ea14..f965ee3 100644 --- a/src/javax/vecmath/Tuple3b.java +++ b/src/javax/vecmath/Tuple3b.java @@ -214,7 +214,7 @@ public abstract class Tuple3b implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { // Since there are no arrays we can just use Object.clone() diff --git a/src/javax/vecmath/Tuple3d.java b/src/javax/vecmath/Tuple3d.java index f4764cc..d43bd77 100644 --- a/src/javax/vecmath/Tuple3d.java +++ b/src/javax/vecmath/Tuple3d.java @@ -652,7 +652,7 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { // Since there are no arrays we can just use Object.clone() diff --git a/src/javax/vecmath/Tuple3f.java b/src/javax/vecmath/Tuple3f.java index b390e5f..bbbecf2 100644 --- a/src/javax/vecmath/Tuple3f.java +++ b/src/javax/vecmath/Tuple3f.java @@ -606,7 +606,7 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { // Since there are no arrays we can just use Object.clone() diff --git a/src/javax/vecmath/Tuple3i.java b/src/javax/vecmath/Tuple3i.java index bc25b94..2fbdb99 100644 --- a/src/javax/vecmath/Tuple3i.java +++ b/src/javax/vecmath/Tuple3i.java @@ -18,7 +18,7 @@ import java.lang.Math; * A 3-element tuple represented by signed integer x,y,z * coordinates. * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public abstract class Tuple3i implements java.io.Serializable, Cloneable { @@ -487,7 +487,7 @@ public abstract class Tuple3i implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { // Since there are no arrays we can just use Object.clone() diff --git a/src/javax/vecmath/Tuple4b.java b/src/javax/vecmath/Tuple4b.java index 1132755..76b1f8d 100644 --- a/src/javax/vecmath/Tuple4b.java +++ b/src/javax/vecmath/Tuple4b.java @@ -231,7 +231,7 @@ public abstract class Tuple4b implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { // Since there are no arrays we can just use Object.clone() diff --git a/src/javax/vecmath/Tuple4d.java b/src/javax/vecmath/Tuple4d.java index 96c5ce4..0abb70c 100644 --- a/src/javax/vecmath/Tuple4d.java +++ b/src/javax/vecmath/Tuple4d.java @@ -736,7 +736,7 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { // Since there are no arrays we can just use Object.clone() diff --git a/src/javax/vecmath/Tuple4f.java b/src/javax/vecmath/Tuple4f.java index 6f0e255..f2d2323 100644 --- a/src/javax/vecmath/Tuple4f.java +++ b/src/javax/vecmath/Tuple4f.java @@ -667,7 +667,7 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { // Since there are no arrays we can just use Object.clone() diff --git a/src/javax/vecmath/Tuple4i.java b/src/javax/vecmath/Tuple4i.java index 8c40ec9..f9251cf 100644 --- a/src/javax/vecmath/Tuple4i.java +++ b/src/javax/vecmath/Tuple4i.java @@ -18,7 +18,7 @@ import java.lang.Math; * A 4-element tuple represented by signed integer x,y,z,w * coordinates. * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public abstract class Tuple4i implements java.io.Serializable, Cloneable { @@ -552,7 +552,7 @@ public abstract class Tuple4i implements java.io.Serializable, Cloneable { * @return a clone of this instance. * @exception OutOfMemoryError if there is not enough memory. * @see java.lang.Cloneable - * @since Java 3D 1.3 + * @since vecmath 1.3 */ public Object clone() { // Since there are no arrays we can just use Object.clone() diff --git a/src/javax/vecmath/Vector4d.java b/src/javax/vecmath/Vector4d.java index 255d81e..1f17751 100644 --- a/src/javax/vecmath/Vector4d.java +++ b/src/javax/vecmath/Vector4d.java @@ -90,7 +90,7 @@ public class Vector4d extends Tuple4d implements java.io.Serializable { * is set to 0. * @param t1 the tuple to be copied * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public Vector4d(Tuple3d t1) { super(t1.x, t1.y, t1.z, 0.0); @@ -112,7 +112,7 @@ public class Vector4d extends Tuple4d implements java.io.Serializable { * is set to 0. * @param t1 the tuple to be copied * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public final void set(Tuple3d t1) { this.x = t1.x; diff --git a/src/javax/vecmath/Vector4f.java b/src/javax/vecmath/Vector4f.java index 5c0e885..7feb3f0 100644 --- a/src/javax/vecmath/Vector4f.java +++ b/src/javax/vecmath/Vector4f.java @@ -94,7 +94,7 @@ public class Vector4f extends Tuple4f implements java.io.Serializable { * is set to 0. * @param t1 the tuple to be copied * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public Vector4f(Tuple3f t1) { super(t1.x, t1.y, t1.z, 0.0f); @@ -116,7 +116,7 @@ public class Vector4f extends Tuple4f implements java.io.Serializable { * is set to 0. * @param t1 the tuple to be copied * - * @since Java 3D 1.2 + * @since vecmath 1.2 */ public final void set(Tuple3f t1) { this.x = t1.x; |