Matrix3f has now a normalize(Matrix3f store) and a normalizeLocal() method
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10649 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
130ddbdfd2
commit
daa3ceee1d
@ -261,6 +261,53 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
|
||||
throw new IndexOutOfBoundsException("Array size must be 9 or 16 in Matrix3f.get().");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize this matrix and store the result in the store parameter that is
|
||||
* returned.
|
||||
*
|
||||
* Note that the original matrix is not altered.
|
||||
*
|
||||
* @param store the matrix to store the result of the normalization. If this
|
||||
* parameter is null a new one is created
|
||||
* @return the normalized matrix
|
||||
*/
|
||||
public Matrix3f normalize(Matrix3f store) {
|
||||
if (store == null) {
|
||||
store = new Matrix3f();
|
||||
}
|
||||
|
||||
float mag = 1.0f / FastMath.sqrt(
|
||||
m00 * m00
|
||||
+ m10 * m10
|
||||
+ m20 * m20);
|
||||
|
||||
store.m00 = m00 * mag;
|
||||
store.m10 = m10 * mag;
|
||||
store.m20 = m20 * mag;
|
||||
|
||||
mag = 1.0f / FastMath.sqrt(
|
||||
m01 * m01
|
||||
+ m11 * m11
|
||||
+ m21 * m21);
|
||||
|
||||
store.m01 = m01 * mag;
|
||||
store.m11 = m11 * mag;
|
||||
store.m21 = m21 * mag;
|
||||
|
||||
store.m02 = store.m10 * store.m21 - store.m11 * store.m20;
|
||||
store.m12 = store.m01 * store.m20 - store.m00 * store.m21;
|
||||
store.m22 = store.m00 * store.m11 - store.m01 * store.m10;
|
||||
return store;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize this matrix
|
||||
* @return this matrix once normalized.
|
||||
*/
|
||||
public Matrix3f normalizeLocal() {
|
||||
return normalize(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>getColumn</code> returns one of three columns specified by the
|
||||
|
Loading…
x
Reference in New Issue
Block a user