Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Peter Robinett authored

Showing 1 changed file with 7 additions and 0 deletions. Show diff stats Hide diff stats

  1. +7 0 matrix.js
7 matrix.js
@@ -540,6 +540,13 @@ Matrix.prototype.notEquals = function notEquals(other) {
540 540 return data[(i<<2) + j];
541 541 }
542 542 */
  543 +// we could do the above with fancy stuff like making the Matrix constructor return a function but for now this is easier:
  544 +Matrix.prototype.get = function get(x, y) {
  545 + if (x < 1 || x > 4 || y < 1 || y > 4) {
  546 + throw "Coordinates out of bounds.";
  547 + }
  548 + return this["m" + x + y];
  549 +}
543 550
544 551 // data accessor for easy conversion to float for OpenGL
545 552 Matrix.prototype.data = function data() {

0 comments on commit da589e7

Please sign in to comment.
Something went wrong with that request. Please try again.