From: Caspian Rychlik-P. <ci...@us...> - 2002-08-26 15:46:46
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector In directory usw-pr-cvs1:/tmp/cvs-serv1733/src/java/org/lwjgl/vector Modified Files: Matrix2f.java Vector3f.java Matrix4f.java Vector2f.java Vector4f.java Matrix3f.java Added Files: Vector.java Matrix.java Log Message: New base classes Vector and Matrix --- NEW FILE: Vector.java --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Vector.java /* * Copyright (c) 2002 Light Weight Java Game Library Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of 'Light Weight Java Game Library' nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.lwjgl.vector; import java.nio.FloatBuffer; import org.lwjgl.Math; /** * $Id$ * * Base class for vectors. * * @author cix_foo <ci...@us...> * @version $Revision$ */ public abstract class Vector { /** * Constructor for Vector. */ public Vector() { super(); } /** * @return the length of the vector */ public final float length() { return Math.sqrt(lengthSquared()); } /** * @return the length squared of the vector */ public abstract float lengthSquared(); /** * Load this vector from a FloatBuffer * @param buf The buffer to load it from, at the current position * @return this */ public abstract Vector load(FloatBuffer buf); /** * Negate a vector * @return this */ public abstract Vector negate(); /** * Normalise this vector * @return this */ public final Vector normalise() { float l = 1.0f / length(); return scale(l); } /** * Store this vector in a FloatBuffer * @param buf The buffer to store it in, at the current position * @return this */ public abstract Vector store(FloatBuffer buf); /** * Scale this vector * @param scale The scale factor * @return this */ public abstract Vector scale(float scale); } --- NEW FILE: Matrix.java --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix.java /* * Copyright (c) 2002 Light Weight Java Game Library Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of 'Light Weight Java Game Library' nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.lwjgl.vector; import java.nio.FloatBuffer; /** * $Id$ * * Base class for matrices. * * @author cix_foo <ci...@us...> * @version $Revision$ */ public abstract class Matrix { /** * Constructor for Matrix. */ public Matrix() { super(); } /** * Set this matrix to be the identity matrix. * @return this */ public abstract Matrix identity(); /** * Invert this matrix * @return this */ public abstract Matrix invert(); /** * Load from a float buffer. The buffer stores the matrix in column major * (OpenGL) order. * * @param buf A float buffer to read from * @return this */ public abstract Matrix load(FloatBuffer buf); /** * Load from a float buffer. The buffer stores the matrix in row major * (mathematical) order. * * @param buf A float buffer to read from * @return this */ public abstract Matrix loadTranspose(FloatBuffer buf); /** * Negate this matrix * @return this */ public abstract Matrix negate(); /** * Store this matrix in a float buffer. The matrix is stored in column * major (openGL) order. * @param buf The buffer to store this matrix in * @return this */ public abstract Matrix store(FloatBuffer buf); /** * Store this matrix in a float buffer. The matrix is stored in row * major (maths) order. * @param buf The buffer to store this matrix in * @return this */ public abstract Matrix storeTranspose(FloatBuffer buf); /** * Transpose this matrix * @return this */ public abstract Matrix transpose(); /** * Set this matrix to 0. * @return this */ public abstract Matrix zero(); /** * @return the determinant of the matrix */ public abstract float determinant(); } Index: Matrix2f.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix2f.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix2f.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Matrix2f.java 24 Aug 2002 21:26:47 -0000 1.4 +++ Matrix2f.java 26 Aug 2002 15:46:39 -0000 1.5 @@ -42,7 +42,7 @@ * @version $Revision$ */ -public class Matrix2f { +public class Matrix2f extends Matrix { public float m00 = 1.0f, m01, m10, m11 = 1.0f; @@ -81,7 +81,7 @@ * @param buf A float buffer to read from * @return this */ - public Matrix2f load(FloatBuffer buf) { + public Matrix load(FloatBuffer buf) { m00 = buf.get(); m10 = buf.get(); @@ -92,17 +92,48 @@ } /** + * Load from a float buffer. The buffer stores the matrix in row major + * (mathematical) order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix loadTranspose(FloatBuffer buf) { + + m00 = buf.get(); + m01 = buf.get(); + m10 = buf.get(); + m11 = buf.get(); + + return this; + } + + /** * Store this matrix in a float buffer. The matrix is stored in column * major (openGL) order. * @param buf The buffer to store this matrix in */ - public void store(FloatBuffer buf) { + public Matrix store(FloatBuffer buf) { buf.put(m00); buf.put(m10); buf.put(m01); buf.put(m11); + return this; } + /** + * Store this matrix in a float buffer. The matrix is stored in row + * major (maths) order. + * @param buf The buffer to store this matrix in + */ + public Matrix storeTranspose(FloatBuffer buf) { + buf.put(m00); + buf.put(m01); + buf.put(m10); + buf.put(m11); + return this; + } + /** @@ -228,7 +259,7 @@ * Transpose this matrix * @return this */ - public Matrix2f transpose() { + public Matrix transpose() { float temp; temp = m01; @@ -261,7 +292,7 @@ * Invert this matrix * @return this */ - public Matrix2f invert() { + public Matrix invert() { return this; } @@ -269,7 +300,7 @@ * Negate this matrix * @return this */ - public Matrix2f negate() { + public Matrix negate() { m00 = -m00; m01 = -m01; @@ -301,7 +332,7 @@ * Set this matrix to be the identity matrix. * @return this */ - public Matrix2f identity() { + public Matrix identity() { m00 = 1.0f; m01 = 0.0f; m10 = 0.0f; @@ -313,7 +344,7 @@ * Set this matrix to 0. * @return this */ - public Matrix2f zero() { + public Matrix zero() { m00 = 0.0f; m01 = 0.0f; m10 = 0.0f; @@ -321,4 +352,11 @@ return this; } + /* (non-Javadoc) + * @see org.lwjgl.vector.Matrix#determinant() + */ + public float determinant() { + return 0; + } + } Index: Vector3f.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Vector3f.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Vector3f.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Vector3f.java 24 Aug 2002 21:12:31 -0000 1.3 +++ Vector3f.java 26 Aug 2002 15:46:39 -0000 1.4 @@ -31,6 +31,8 @@ */ package org.lwjgl.vector; +import java.nio.FloatBuffer; + import org.lwjgl.Math; /** @@ -42,7 +44,7 @@ * @version $Revision$ */ -public class Vector3f { +public class Vector3f extends Vector { public float x, y, z; @@ -91,13 +93,6 @@ } /** - * @return the length of the vector - */ - public float length() { - return Math.sqrt(lengthSquared()); - } - - /** * @return the length squared of the vector */ public float lengthSquared() { @@ -117,11 +112,45 @@ return this; } + /** + * Add a vector to another vector and place the result in a destination + * vector. + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return the sum of left and right in dest + */ + public static Vector3f add(Vector3f left, Vector3f right, Vector3f dest) { + if (dest == null) + return new Vector3f(left.x + right.x, left.y + right.y, left.z + right.z); + else { + return dest.set(left.x + right.x, left.y + right.y, left.z + right.z); + } + } + + /** + * Subtract a vector from another vector and place the result in a destination + * vector. + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return left minus right in dest + */ + public static Vector3f sub(Vector3f left, Vector3f right, Vector3f dest) { + if (dest == null) + return new Vector3f(left.x - right.x, left.y - right.y, left.z - right.z); + else { + return dest.set(left.x - right.x, left.y - right.y, left.z - right.z); + } + } + + + /** * Negate a vector * @return this */ - public Vector3f negate() { + public Vector negate() { x = -x; y = -y; z = -z; @@ -129,17 +158,20 @@ } /** - * Normalise this vector - * @return this + * Negate a vector and place the result in a destination vector. + * @param dest The destination vector or null if a new vector is to be created + * @return the negated vector */ - public Vector3f normalise() { - float l = 1.0f / length(); - x *= l; - y *= l; - z *= l; - return this; + public Vector3f negate(Vector3f dest) { + if (dest == null) + dest = new Vector3f(); + dest.x = -x; + dest.y = -y; + dest.z = -z; + return dest; } + /** * Normalise this vector and place the result in another vector. * @param dest The destination vector, or null if a new vector is to be created @@ -182,4 +214,36 @@ return Math.acos(dls); } + /* (non-Javadoc) + * @see org.lwjgl.vector.Vector#load(FloatBuffer) + */ + public Vector load(FloatBuffer buf) { + return null; + } + + /* (non-Javadoc) + * @see org.lwjgl.vector.Vector#scale(float) + */ + public Vector scale(float scale) { + + x *= scale; + y *= scale; + z *= scale; + + return this; + + } + + /* (non-Javadoc) + * @see org.lwjgl.vector.Vector#store(FloatBuffer) + */ + public Vector store(FloatBuffer buf) { + + buf.put(x); + buf.put(y); + buf.put(z); + + return this; + } + } Index: Matrix4f.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix4f.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix4f.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Matrix4f.java 24 Aug 2002 21:35:20 -0000 1.5 +++ Matrix4f.java 26 Aug 2002 15:46:39 -0000 1.6 @@ -38,7 +38,7 @@ * * @author foo */ -public class Matrix4f { +public class Matrix4f extends Matrix { /** * Set this matrix to be the identity matrix. * @return this @@ -157,6 +157,35 @@ } /** + * Load from a float buffer. The buffer stores the matrix in row major + * (maths) order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix4f loadTranspose(FloatBuffer buf) { + + m00 = buf.get(); + m01 = buf.get(); + m02 = buf.get(); + m03 = buf.get(); + m10 = buf.get(); + m11 = buf.get(); + m12 = buf.get(); + m13 = buf.get(); + m20 = buf.get(); + m21 = buf.get(); + m22 = buf.get(); + m23 = buf.get(); + m30 = buf.get(); + m31 = buf.get(); + m32 = buf.get(); + m33 = buf.get(); + + return this; + } + + /** * Store this matrix in a float buffer. The matrix is stored in column * major (openGL) order. * @param buf The buffer to store this matrix in @@ -179,6 +208,30 @@ buf.put(m23); buf.put(m33); } + + /** + * Store this matrix in a float buffer. The matrix is stored in row + * major (maths) order. + * @param buf The buffer to store this matrix in + */ + public void storeTranspose(FloatBuffer buf) { + buf.put(m00); + buf.put(m01); + buf.put(m02); + buf.put(m03); + buf.put(m10); + buf.put(m11); + buf.put(m12); + buf.put(m13); + buf.put(m20); + buf.put(m21); + buf.put(m22); + buf.put(m23); + buf.put(m30); + buf.put(m31); + buf.put(m32); + buf.put(m33); + } /** Index: Vector2f.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Vector2f.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Vector2f.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Vector2f.java 24 Aug 2002 21:12:31 -0000 1.3 +++ Vector2f.java 26 Aug 2002 15:46:39 -0000 1.4 @@ -31,6 +31,8 @@ */ package org.lwjgl.vector; +import java.nio.FloatBuffer; + import org.lwjgl.Math; /** @@ -42,7 +44,7 @@ * @version $Revision$ */ -public class Vector2f { +public class Vector2f extends Vector { public float x, y; @@ -89,13 +91,6 @@ } /** - * @return the length of the vector - */ - public float length() { - return Math.sqrt(lengthSquared()); - } - - /** * @return the length squared of the vector */ public float lengthSquared() { @@ -118,23 +113,26 @@ * Negate a vector * @return this */ - public Vector2f negate() { + public Vector negate() { x = -x; y = -y; return this; } /** - * Normalise this vector - * @return this + * Negate a vector and place the result in a destination vector. + * @param dest The destination vector or null if a new vector is to be created + * @return the negated vector */ - public Vector2f normalise() { - float l = 1.0f / length(); - x *= l; - y *= l; - return this; + public Vector2f negate(Vector2f dest) { + if (dest == null) + dest = new Vector2f(); + dest.x = -x; + dest.y = -y; + return dest; } + /** * Normalise this vector and place the result in another vector. * @param dest The destination vector, or null if a new vector is to be created @@ -176,5 +174,70 @@ dls = 1.0f; return Math.acos(dls); } + + /** + * Add a vector to another vector and place the result in a destination + * vector. + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return the sum of left and right in dest + */ + public static Vector2f add(Vector2f left, Vector2f right, Vector2f dest) { + if (dest == null) + return new Vector2f(left.x + right.x, left.y + right.y); + else { + return dest.set(left.x + right.x, left.y + right.y); + } + } + + /** + * Subtract a vector from another vector and place the result in a destination + * vector. + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return left minus right in dest + */ + public static Vector2f sub(Vector2f left, Vector2f right, Vector2f dest) { + if (dest == null) + return new Vector2f(left.x - right.x, left.y - right.y); + else { + return dest.set(left.x - right.x, left.y - right.y); + } + } + + /** + * Store this vector in a FloatBuffer + * @param buf The buffer to store it in, at the current position + * @return this + */ + public Vector store(FloatBuffer buf) { + buf.put(x); + buf.put(y); + return this; + } + + /** + * Load this vector from a FloatBuffer + * @param buf The buffer to load it from, at the current position + * @return this + */ + public Vector load(FloatBuffer buf) { + x = buf.get(); + y = buf.get(); + return this; + } + /* (non-Javadoc) + * @see org.lwjgl.vector.Vector#scale(float) + */ + public Vector scale(float scale) { + + x *= scale; + y *= scale; + + return this; + } + } Index: Vector4f.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Vector4f.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Vector4f.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Vector4f.java 24 Aug 2002 21:12:31 -0000 1.3 +++ Vector4f.java 26 Aug 2002 15:46:39 -0000 1.4 @@ -31,6 +31,8 @@ */ package org.lwjgl.vector; +import java.nio.FloatBuffer; + import org.lwjgl.Math; /** @@ -42,7 +44,7 @@ * @version $Revision$ */ -public class Vector4f { +public class Vector4f extends Vector { public float x, y, z, w; @@ -93,13 +95,6 @@ } /** - * @return the length of the vector - */ - public float length() { - return Math.sqrt(lengthSquared()); - } - - /** * @return the length squared of the vector */ public float lengthSquared() { @@ -120,11 +115,44 @@ return this; } + /** + * Add a vector to another vector and place the result in a destination + * vector. + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return the sum of left and right in dest + */ + public static Vector4f add(Vector4f left, Vector4f right, Vector4f dest) { + if (dest == null) + return new Vector4f(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); + else { + return dest.set(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); + } + } + + /** + * Subtract a vector from another vector and place the result in a destination + * vector. + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination vector, or null if a new vector is to be created + * @return left minus right in dest + */ + public static Vector4f sub(Vector4f left, Vector4f right, Vector4f dest) { + if (dest == null) + return new Vector4f(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); + else { + return dest.set(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); + } + } + + /** * Negate a vector * @return this */ - public Vector4f negate() { + public Vector negate() { x = -x; y = -y; z = -z; @@ -133,18 +161,21 @@ } /** - * Normalise this vector - * @return this + * Negate a vector and place the result in a destination vector. + * @param dest The destination vector or null if a new vector is to be created + * @return the negated vector */ - public Vector4f normalise() { - float l = 1.0f / length(); - x *= l; - y *= l; - z *= l; - w *= l; - return this; + public Vector4f negate(Vector4f dest) { + if (dest == null) + dest = new Vector4f(); + dest.x = -x; + dest.y = -y; + dest.z = -z; + dest.w = -w; + return dest; } + /** * Normalise this vector and place the result in another vector. * @param dest The destination vector, or null if a new vector is to be created @@ -187,4 +218,35 @@ return Math.acos(dls); } + /* (non-Javadoc) + * @see org.lwjgl.vector.Vector#load(FloatBuffer) + */ + public Vector load(FloatBuffer buf) { + return null; + } + + /* (non-Javadoc) + * @see org.lwjgl.vector.Vector#scale(float) + */ + public Vector scale(float scale) { + x *= scale; + y *= scale; + z *= scale; + w *= scale; + return this; + } + + /* (non-Javadoc) + * @see org.lwjgl.vector.Vector#store(FloatBuffer) + */ + public Vector store(FloatBuffer buf) { + + buf.put(x); + buf.put(y); + buf.put(z); + buf.put(w); + + return this; + } + } Index: Matrix3f.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix3f.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix3f.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Matrix3f.java 24 Aug 2002 21:35:20 -0000 1.5 +++ Matrix3f.java 26 Aug 2002 15:46:39 -0000 1.6 @@ -42,7 +42,7 @@ * @version $Revision$ */ -public class Matrix3f { +public class Matrix3f extends Matrix { public float m00 = 1.0f, m01, @@ -87,7 +87,7 @@ * @param buf A float buffer to read from * @return this */ - public Matrix3f load(FloatBuffer buf) { + public Matrix load(FloatBuffer buf) { m00 = buf.get(); m10 = buf.get(); @@ -103,11 +103,33 @@ } /** + * Load from a float buffer. The buffer stores the matrix in row major + * (maths) order. + * + * @param buf A float buffer to read from + * @return this + */ + public Matrix loadTranspose(FloatBuffer buf) { + + m00 = buf.get(); + m01 = buf.get(); + m02 = buf.get(); + m10 = buf.get(); + m11 = buf.get(); + m12 = buf.get(); + m20 = buf.get(); + m21 = buf.get(); + m22 = buf.get(); + + return this; + } + + /** * Store this matrix in a float buffer. The matrix is stored in column * major (openGL) order. * @param buf The buffer to store this matrix in */ - public void store(FloatBuffer buf) { + public Matrix store(FloatBuffer buf) { buf.put(m00); buf.put(m10); buf.put(m20); @@ -117,8 +139,27 @@ buf.put(m02); buf.put(m12); buf.put(m22); + return this; } + /** + * Store this matrix in a float buffer. The matrix is stored in row + * major (maths) order. + * @param buf The buffer to store this matrix in + */ + public Matrix storeTranspose(FloatBuffer buf) { + buf.put(m00); + buf.put(m01); + buf.put(m02); + buf.put(m10); + buf.put(m11); + buf.put(m12); + buf.put(m20); + buf.put(m21); + buf.put(m22); + return this; + } + /** @@ -269,7 +310,7 @@ * Transpose this matrix * @return this */ - public Matrix3f transpose() { + public Matrix transpose() { float f = m10; m10 = m01; m01 = f; @@ -324,7 +365,7 @@ * Invert this matrix * @return this */ - public Matrix3f invert() { + public Matrix invert() { return this; } @@ -332,7 +373,7 @@ * Negate this matrix * @return this */ - public Matrix3f negate() { + public Matrix negate() { m00 = -m00; m01 = -m02; m02 = -m01; |