@@ -317,17 +317,19 @@ quatIdentity:function(){
317317} ,
318318/**
319319 * Returns a copy of a 4x4 matrix.
320+ * @param {Array<number> } mat A 4x4 matrix.
320321 * @return {Array<number> }
321322 */
322323mat4copy :function ( mat ) {
323324 return mat . slice ( 0 , 16 ) ;
324325} ,
325326/**
326327 * Returns a copy of a 4-element vector.
328+ * @param {Array<number> } mat A 4-element vector.
327329 * @return {Array<number> }
328330 */
329- vec4copy :function ( mat ) {
330- return mat . slice ( 0 , 4 ) ;
331+ vec4copy :function ( vec ) {
332+ return vec . slice ( 0 , 4 ) ;
331333} ,
332334/**
333335 * Finds the inverse of a 4x4 matrix.
@@ -433,11 +435,21 @@ quatConjugate:function(quat){
433435 return [ - quat [ 0 ] , - quat [ 1 ] , - quat [ 2 ] , quat [ 3 ] ] ;
434436} ,
435437/**
436- * Inverts the rotation given in this quaternion, then normalizes the result ;
438+ * Inverts the rotation given in this quaternion;
437439 * returns a new quaternion.
438440 * @param {Array<number> } quat A quaternion, containing four elements.
439441 * @return {Array<number> }
440442 */
443+ quatInvert :function ( quat ) {
444+ var lsq = 1.0 / GLMath . quatDot ( quat , quat ) ;
445+ return GLMath . vec4scaleInPlace ( lsq ,
446+ GLMath . quatConjugate ( quat ) )
447+ } ,
448+ /**
449+ * @deprecated This method incorrectly calculates a quaternion's
450+ * inverse; use quatInvert instead. This method will be changed to
451+ * be equivalent to quatInvert in a future version.
452+ */
441453quatInverse :function ( quat ) {
442454 return GLMath . quatNormInPlace (
443455 GLMath . quatConjugate ( quat ) ) ;
@@ -758,10 +770,12 @@ quatRotate:function(quat,angle,v,vy,vz){
758770 GLMath . quatFromAxisAngle ( angle , v , vy , vz ) ) ;
759771} ,
760772/**
761- * Transforms a vector using a quaternion's rotation.
773+ * Transforms a 4-element vector using a quaternion's rotation.
762774 * @param {Array<number> } q A quaternion describing
763775 * the rotation.
764- * @param {Array<number> } v The vector to transform.
776+ * @param {Array<number> } v A 4-element vector to transform.
777+ * To transform a 3D point, set the vector's 4th element (zero-based
778+ * index 3) to 1.
765779 * @return {Array<number> } The transformed vector.
766780 */
767781quatTransform :function ( q , v ) {
@@ -1188,7 +1202,9 @@ mat4ortho:function(l,r,b,t,n,f){
11881202 * This method assumes a right-handed coordinate system, such as
11891203 * OpenGL's. To adjust the result of this method to a left-handed system,
11901204 * such as Direct3D's, reverse the sign of the 9th, 10th, 11th, and 12th
1191- * elements of the result (zero-based indices 8, 9, 10, and 11).
1205+ * elements of the result (zero-based indices 8, 9, 10, and 11).<p>
1206+ * This is the same as mat4ortho2d() with the near clipping plane
1207+ * set to -1 and the far clipping plane set to 1.
11921208 * @param {number } l Leftmost coordinate of the 2D view.
11931209 * @param {number } r Rightmost coordinate of the 2D view.
11941210 * (Note that r can be greater than l or vice versa.)
@@ -1281,8 +1297,8 @@ mat4scaleInPlace:function(mat,v3,v3y,v3z){
12811297 * matrix (input matrix) describes a translation and the second
12821298 * matrix describes a scaling, the multiplied matrix will describe
12831299 * the effect of scaling then translation.
1284- * @param {* } a The first matrix.
1285- * @param {* } b The second matrix.
1300+ * @param {Array<number> } a The first matrix.
1301+ * @param {Array<number> } b The second matrix.
12861302 * @return {Array<number> } The resulting 4x4 matrix.
12871303 */
12881304mat4multiply :function ( a , b ) {
0 commit comments