Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a get() method to Matrix so that it's easier to get a specific el…

…ement.
  • Loading branch information...
commit da589e798211e2b2c10aa297a7d02959b0e70ccb 1 parent c6997fb
@pr1001 authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 matrix.js
View
7 matrix.js
@@ -540,6 +540,13 @@ Matrix.prototype.notEquals = function notEquals(other) {
return data[(i<<2) + j];
}
*/
+// we could do the above with fancy stuff like making the Matrix constructor return a function but for now this is easier:
+Matrix.prototype.get = function get(x, y) {
+ if (x < 1 || x > 4 || y < 1 || y > 4) {
+ throw "Coordinates out of bounds.";
+ }
+ return this["m" + x + y];
+}
// data accessor for easy conversion to float for OpenGL
Matrix.prototype.data = function data() {
Please sign in to comment.
Something went wrong with that request. Please try again.