Class Matrix3
java.lang.Object
org.web3d.vrml.scripting.ecmascript.builtin.FieldScriptableObject
org.web3d.vrml.scripting.ecmascript.builtin.Matrix3
- All Implemented Interfaces:
org.mozilla.javascript.Scriptable
ECMAScript Matrix3 builtin object.
The implementation of all the functionality in this class is according to the Matrix and Quaternion FAQ, which is currently located at: http://www.j3d.org/matrix_faq/
The spec is sort of a bit wishy-washy about how the flat references of array indices. Internally the matrix is stored with the translations values down the right "column" where the X3D spec has them across the bottom. Not entirely convinced that this is correct. Just makes it easy to check this code against the FAQ code, which uses them stored in the same way.
- Version:
- $Revision: 1.2 $
- Author:
- Justin Couch
-
Field Summary
Fields inherited from class org.web3d.vrml.scripting.ecmascript.builtin.FieldScriptableObject
BAD_FORMAT_MSG, dataChanged, INVALID_TYPE_MSG, readOnly, READONLY_MSG, scriptField
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget
(int index, org.mozilla.javascript.Scriptable start) Get the value of the named function.boolean
has
(int index, org.mozilla.javascript.Scriptable start) void
jsConstructor
(double f11, double f12, double f13, double f21, double f22, double f23, double f31, double f32, double f33) boolean
jsFunction_equals
(Object val) Comparison of this object to another of the same type.void
jsFunction_getTransform
(org.mozilla.javascript.Scriptable tx, org.mozilla.javascript.Scriptable rot, org.mozilla.javascript.Scriptable sc) Get the value of the transform.Create the inverse of the matrix and return that in a new matrix.jsFunction_multLeft
(org.mozilla.javascript.Scriptable m) Multiply the passed matrix this matrix and return the value in a new matrix instance.jsFunction_multMatrixVec
(org.mozilla.javascript.Scriptable vector) Return a vector that is this multiplied by the given vector as a column.jsFunction_multRight
(org.mozilla.javascript.Scriptable m) Multiply this matrix by the passed matrix and return the value in a new matrix instance.jsFunction_multVecMatrix
(org.mozilla.javascript.Scriptable vector) Return a vector that is this multiplied by the given vector as a row.void
jsFunction_setTransform
(org.mozilla.javascript.Scriptable trans, org.mozilla.javascript.Scriptable rot, org.mozilla.javascript.Scriptable scale, org.mozilla.javascript.Scriptable scaleOrient, org.mozilla.javascript.Scriptable center) Set the transform to the new values of translation, rotation, scale etc.Creates a string version of this node.Create the transpose of this matrix and return it in a new matrix.void
Set an indexed property.void
Sets the named property with a new value.toString()
Format the internal values of this matrix as a string.Methods inherited from class org.web3d.vrml.scripting.ecmascript.builtin.FieldScriptableObject
delete, delete, getClassName, getDefaultValue, getIds, getParentScope, getPrototype, has, hasChanged, hasInstance, locateFunction, registerFunction, setParentScope, setPrototype, setReadOnly, setScriptField
-
Constructor Details
-
Matrix3
public Matrix3()Default public constructor required by Rhino for when created by an Ecmascript call. -
Matrix3
public Matrix3(double[] data) Default public constructor required by Rhino for when created by an Ecmascript call.- Parameters:
data
- a double array for constructing this Matrix
-
-
Method Details
-
jsConstructor
public void jsConstructor(double f11, double f12, double f13, double f21, double f22, double f23, double f31, double f32, double f33) -
has
public boolean has(int index, org.mozilla.javascript.Scriptable start) - Specified by:
has
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
has
in classFieldScriptableObject
-
get
- Specified by:
get
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
get
in classFieldScriptableObject
-
get
Get the value of the named function. If no function object is registered for this name, the method will return null.- Specified by:
get
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
get
in classFieldScriptableObject
- Parameters:
name
- The variable namestart
- The object where the lookup began- Returns:
- the corresponding function object or null
-
put
Set an indexed property. Only accept the first 16 values.- Specified by:
put
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
put
in classFieldScriptableObject
- Parameters:
index
- The index of the property to look upstart
- The object where the lookup beganvalue
- The value of the object to use
-
put
Sets the named property with a new value. A put usually means changing the entire property. So, if the property has changed using an operation likee = new SFColor(0, 1, 0);
then a whole new object is passed to us.- Specified by:
put
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
put
in classFieldScriptableObject
- Parameters:
name
- The name of the property to definestart
- The object who's property is being setvalue
- The value being requested
-
jsFunction_setTransform
public void jsFunction_setTransform(org.mozilla.javascript.Scriptable trans, org.mozilla.javascript.Scriptable rot, org.mozilla.javascript.Scriptable scale, org.mozilla.javascript.Scriptable scaleOrient, org.mozilla.javascript.Scriptable center) Set the transform to the new values of translation, rotation, scale etc. Takes a variable list of arguments. Anything more than 5 and we ignore the extras. There may by up to 5 items in the array. Zero items means to set the array to an identity matrix. After that, the arguments are:- Parameters:
trans
- translationrot
- rotationscale
- scalescaleOrient
- scaleOrientationcenter
- center
-
jsFunction_getTransform
public void jsFunction_getTransform(org.mozilla.javascript.Scriptable tx, org.mozilla.javascript.Scriptable rot, org.mozilla.javascript.Scriptable sc) Get the value of the transform.- Parameters:
tx
- The transform componentrot
- The orientation componentsc
- The scale component
-
jsFunction_inverse
Create the inverse of the matrix and return that in a new matrix.- Returns:
- TODO "not implemented"
-
jsFunction_transpose
Create the transpose of this matrix and return it in a new matrix.- Returns:
- A matrix containing the transpose of this one
-
jsFunction_multLeft
Multiply the passed matrix this matrix and return the value in a new matrix instance.- Parameters:
m
- The left hand matrix to use- Returns:
- A new matrix with the new values
-
jsFunction_multRight
Multiply this matrix by the passed matrix and return the value in a new matrix instance.- Parameters:
m
- The left hand matrix to use- Returns:
- A new matrix with the new values
-
jsFunction_multVecMatrix
Return a vector that is this multiplied by the given vector as a row.- Parameters:
vector
- The row vector to use for multiplication- Returns:
- A new vector containing the results
-
jsFunction_multMatrixVec
Return a vector that is this multiplied by the given vector as a column.- Parameters:
vector
- The column vector to use for multiplication- Returns:
- A new vector containing the results
-
jsFunction_toString
Creates a string version of this node. Just calls the standard toString() method of the object.- Returns:
- A VRML string representation of the field
-
jsFunction_equals
Comparison of this object to another of the same type. Just calls the standard equals() method of the object.- Parameters:
val
- The value to compare to this object- Returns:
- true if the components of the object are the same
-
toString
-