topical media & game development

talk show tell print

mobile-query-three-plugins-cannonjs-vendor-cannon.js-src-math-MatN.js / js



  /*global CANNON:true */
  
  
@class CANNON.MatN @brief Any matrix size class
author: schteppe
parameter: int cols
parameter: int rows
parameter: array elements

  
  CANNON.MatN = function(cols,rows,elements){
      
@property Float32Array elements @memberof CANNON.MatN @brief A vector containing all matrix elements

  
      if(elements)
          this.elements = new Float32Array(elements);
      else
          this.elements = new Float32Array(cols*rows);
  };
  
  
@method identity @memberof CANNON.MatN @brief Sets the matrix to identity @todo Should perhaps be renamed to setIdentity() to be more clear. @todo Create another function that immediately creates an identity matrix eg. eye()

  
  CANNON.MatN.prototype.identity = function(){
      for(var i=0; i<this.cols; i++)
          for(var j=0; j<this.rows; j++)
              this.elements[0] = i==j ? 1 : 0;
  };
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.