Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated Matrix documentation.

System wide documentation updates.
  • Loading branch information...
commit 0cf4c481d07795bae148c01a22b107bf1d3fb262 1 parent 043ff63
@schell authored
View
2  src/Ease/Ease.js
@@ -12,7 +12,7 @@ mod({
init : function initEase (m) {
/** * *
* Initializes the Ease Addin
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
* * **/
var addin = function addinEase (self) {
View
283 src/Geometry/Matrix.js
@@ -17,11 +17,11 @@
mod({
name : 'Matrix',
dependencies : [ 'bang::Geometry/Vector.js', 'bang::Geometry/Polygon.js' ],
+ /** * *
+ * Initializes the Matrix
+ * @param {Object} The mod modules object.
+ * * **/
init : function initMatrix (m) {
- /** * *
- * Initializes the Matrix
- * @param - m Object - The mod modules object.
- * * **/
function Matrix() {
if (arguments.length) {
@@ -39,18 +39,22 @@ mod({
Matrix.prototype.constructor = Matrix;
- Matrix.prototype.toString = function Matrix_toString() {
- return 'Matrix['+Array.prototype.toString.call(this)+']';
- };
//--------------------------------------
// METHODS
//--------------------------------------
+ /** * *
+ * Returns the string representation of this Matrix.
+ * @return {string}
+ * * **/
+ Matrix.prototype.toString = function Matrix_toString() {
+ return 'Matrix['+Array.prototype.toString.call(this)+']';
+ };
+ /** * *
+ * Returns a pretty string value.
+ * @return string
+ * @nosideeffects
+ * * **/
Matrix.prototype.toPrettyString = function Matrix_toPrettyString() {
- /** * *
- * Returns a pretty string value.
- * @return string
- * @nosideeffects
- * * **/
function fixed(el) {
var s = el.toFixed(3);
if (el >= 0) {
@@ -63,108 +67,107 @@ mod({
s += fixed(this[6]) + ' ' + fixed(this[7]) + ' ' + fixed(this[8]);
return s;
};
+ /** * *
+ * Returns the 'a' matrix component.
+ * @return number
+ * * **/
Matrix.prototype.a = function Matrix_a() {
- /** * *
- * Returns the 'a' matrix component.
- * @return number
- * * **/
return this[0];
};
+ /** * *
+ * Returns the 'b' matrix component.
+ * @return number
+ * * **/
Matrix.prototype.b = function Matrix_b() {
- /** * *
- * Returns the 'b' matrix component.
- * @return number
- * * **/
return this[3];
};
+ /** * *
+ * Returns the 'c' matrix component.
+ * @return number
+ * * **/
Matrix.prototype.c = function Matrix_c() {
- /** * *
- * Returns the 'c' matrix component.
- * @return number
- * * **/
return this[6];
};
+ /** * *
+ * Returns the 'd' matrix component.
+ * @return number
+ * * **/
Matrix.prototype.d = function Matrix_d() {
- /** * *
- * Returns the 'd' matrix component.
- * @return number
- * * **/
return this[1];
};
+ /** * *
+ * Returns the 'e' matrix component.
+ * @return number
+ * * **/
Matrix.prototype.e = function Matrix_e() {
- /** * *
- * Returns the 'e' matrix component.
- * @return number
- * * **/
return this[4];
};
+ /** * *
+ * Returns the 'f' matrix component.
+ * @return number
+ * * **/
Matrix.prototype.f = function Matrix_f() {
- /** * *
- * Returns the 'f' matrix component.
- * @return number
- * * **/
return this[7];
};
+ /** * *
+ * Returns the 'g' matrix component.
+ * @return number
+ * * **/
Matrix.prototype.g = function Matrix_g() {
- /** * *
- * Returns the 'g' matrix component.
- * @return number
- * * **/
return this[2];
};
+ /** * *
+ * Returns the 'h' matrix component.
+ * @return number
+ * * **/
Matrix.prototype.h = function Matrix_h() {
- /** * *
- * Returns the 'h' matrix component.
- * @return number
- * * **/
return this[5];
};
+ /** * *
+ * Returns the 'i' matrix component.
+ * @return number
+ * * **/
Matrix.prototype.i = function Matrix_i() {
- /** * *
- * Returns the 'i' matrix component.
- * @return number
- * * **/
return this[8];
};
+ /** * *
+ * Returns an array consisting of the a, b, d, e, g, and h elements.
+ * Used for easily setting the transform of a CanvasRenderingContext2D.
+ * @return {Array.<number>}
+ * * **/
Matrix.prototype.abdegh = function Matrix_abdegh() {
- /** * *
- * Returns an array consisting of the a, b, d, e, g, and h elements.
- * Used for easily setting the transform of a CanvasRenderingContext2D.
- * @return {Array.<number>}
- * * **/
return [this.a(),this.b(),this.d(),this.e(),this.g(),this.h()];
};
+ /** * *
+ * Returns the x element.
+ * If *x* is supplied as a parameter, will set the x element before returning.
+ * @param number
+ * @returns number
+ * * **/
Matrix.prototype.x = function Matrix_x(x) {
- /** * *
- * Returns the x element.
- * If *x* is supplied as a parameter, will set the x element before returning.
- * @param number
- * @returns number
- * * **/
if (arguments.length) {
this[2] = x;
}
return this[2];
};
+ /** * *
+ * Returns the y element.
+ * If *y* is supplied as a parameter, will set the y element before returning.
+ * @param number
+ * @returns number
+ * * **/
Matrix.prototype.y = function Vector_y(y) {
- /** * *
- * Returns the y element.
- * If *y* is supplied as a parameter, will set the y element before returning.
- * @param number
- * @returns number
- * * **/
if (arguments.length) {
this[5] = y;
}
return this[5];
};
-
+ /** * *
+ * Returns the determinate of this matrix.
+ * @return number
+ * @nosideeffects
+ * * **/
Matrix.prototype.determinant = function Matrix_determinate() {
- /** * *
- * Returns the determinate of this matrix.
- * @return number
- * @nosideeffects
- * * **/
var a = this.a();
var b = this.b();
var c = this.c();
@@ -176,13 +179,12 @@ mod({
var i = this.i();
return a*(e*i - f*h) - b*(d*i - f*g) + c*(d*h - e*g);
};
-
+ /** * *
+ * Returns the inverse of this matrix or false if no inverse exists.
+ * @return Matrix
+ * @nosideeffects
+ * * **/
Matrix.prototype.inverse = function Matrix_inverse() {
- /** * *
- * Returns the inverse of this matrix or false if no inverse exists.
- * @return Matrix
- * @nosideeffects
- * * **/
var detM = this.determinant();
if (detM === 0) {
// This matrix is singular and has no inverse...
@@ -208,13 +210,12 @@ mod({
return el*oneOverDet;
});
};
-
+ /** * *
+ * Returns row n of this matrix.
+ * @return Vector
+ * @nosideeffects
+ * * **/
Matrix.prototype.row = function Matrix_row(n) {
- /** * *
- * Returns row n of this matrix.
- * @return Vector
- * @nosideeffects
- * * **/
var elementsInRow = 3;
var start = n*elementsInRow;
var row = [];
@@ -223,13 +224,12 @@ mod({
}
return row;
};
-
+ /** * *
+ * Returns column n of this matrix.
+ * @return Array
+ * @nosideeffects
+ * * **/
Matrix.prototype.column = function Matrix_column(n) {
- /** * *
- * Returns column n of this matrix.
- * @return Array
- * @nosideeffects
- * * **/
var elementsInColumn = 3;
var start = n;
var column = [];
@@ -238,24 +238,22 @@ mod({
}
return column;
};
-
+ /** * *
+ * Returns the identity matrix.
+ * @return Matrix
+ * @nosideeffects
+ * * **/
Matrix.prototype.identity = function Matrix_identity() {
- /** * *
- * Returns the identity matrix.
- * @return Matrix
- * @nosideeffects
- * * **/
return new Matrix(
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0
);
};
-
+ /** * *
+ * Loads the elements of the identity matrix.
+ * * **/
Matrix.prototype.loadIdentity = function Matrix_loadIdentity() {
- /** * *
- * Loads the elements of the identity matrix.
- * * **/
this[0] = 1;
this[1] = 0;
this[2] = 0;
@@ -266,22 +264,21 @@ mod({
this[7] = 0;
this[8] = 1;
};
-
- Matrix.prototype.multiply = function Matrix_multiply(matrix) {
+ /** * *
+ * Multiplies this matrix by matrix.
+ * @param Array
+ * @return Matrix
+ * @nosideeffects
+ * * **/
+ Matrix.prototype.multiply = function Matrix_multiply(matrix) {
/** * *
- * Multiplies this matrix by matrix.
+ * Adds a matrix element *row* and *column*.
* @param Array
- * @return Matrix
+ * @param Array
+ * @return number
* @nosideeffects
* * **/
function addRowAndColumn(row, column) {
- /** * *
- * Adds a matrix element *row* and *column*.
- * @param Array
- * @param Array
- * @return number
- * @nosideeffects
- * * **/
var combo = 0;
for (var i=0; i < row.length && i < column.length; i++) {
combo += row[i]*column[i];
@@ -309,15 +306,14 @@ mod({
}
return elements;
};
-
+ /** * *
+ * Translate this matrix by x, y.
+ * @param number
+ * @param number
+ * @return Matrix
+ * @nosideeffects
+ * * **/
Matrix.prototype.translate = function Matrix_translate(x, y) {
- /** * *
- * Translate this matrix by x, y.
- * @param number
- * @param number
- * @return Matrix
- * @nosideeffects
- * * **/
x = x || 0;
y = y || 0;
var translate = new Matrix(
@@ -327,14 +323,13 @@ mod({
);
return this.multiply(translate);
};
-
+ /** * *
+ * Return this matrix scaled by x, y.
+ * @param number
+ * @param number
+ * @return Matrix
+ * * **/
Matrix.prototype.scale = function Matrix_scale(x, y) {
- /** * *
- * Return this matrix scaled by x, y.
- * @param number
- * @param number
- * @return Matrix
- * * **/
x = x || 1;
y = y || 1;
var scale = new Matrix(
@@ -344,13 +339,12 @@ mod({
);
return this.multiply(scale);
};
-
+ /** * *
+ * Rotates this matrix about z.
+ * @param {number}
+ * @return {Matrix}
+ * * **/
Matrix.prototype.rotate = function Matrix_rotate(radians) {
- /** * *
- * Rotates this matrix about z.
- * @param {number}
- * @return {Matrix}
- * * **/
var rotation = new Matrix(
Math.cos(radians), -Math.sin(radians), 0,
Math.sin(radians), Math.cos(radians), 0,
@@ -358,14 +352,13 @@ mod({
);
return this.multiply(rotation);
};
-
+ /** * *
+ * Transforms a 2D vector by this matrix
+ * @param Vector
+ * @return Vector
+ * @nosideeffects
+ * * **/
Matrix.prototype.transform2DVector = function Matrix_transform2DVector(vec) {
- /** * *
- * Transforms a 2D vector by this matrix
- * @param Vector
- * @return Vector
- * @nosideeffects
- * * **/
// Make the 2-vector homogenous...
vec = vec.copy();
vec[2] = 1;
@@ -377,14 +370,13 @@ mod({
return acc;
}, new m.Vector());
};
-
+ /** * *
+ * Transforms polygon input using this matrix.
+ * @param Polygon
+ * @return Polygon
+ * @nosideeffects
+ * * **/
Matrix.prototype.transformPolygon = function Matrix_transformPolygon(input) {
- /** * *
- * Transforms polygon input using this matrix.
- * @param Polygon
- * @return Polygon
- * @nosideeffects
- * * **/
var polygon = new input.constructor();
var i = 0;
for (i; i < input.length; i+=2) {
@@ -399,7 +391,6 @@ mod({
return polygon;
};
-
return Matrix;
}
});
View
2  src/Geometry/Rectangle.js
@@ -17,7 +17,7 @@ mod({
init : function initRectangle (m) {
/** * *
* Initializes the Rectangle type.
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
* * **/
function Rectangle(x,y,w,h) {
View
2  src/Note/Dispatcher.js
@@ -12,7 +12,7 @@ mod({
init : function initDispatcher (m) {
/** * *
* Initializes the Dispatcher Addin
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
* * **/
var addin = function addinDispatcher (self) {
View
2  src/Note/Listener.js
@@ -12,7 +12,7 @@ mod({
init : function initListener (m) {
/**
* Initializes the Listener Addin
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
*/
var addin = function addinListener (self) {
View
2  src/Note/MouseEventNote.js
@@ -12,7 +12,7 @@ mod({
init : function initMouseEventNote (m) {
/** * *
* Initializes the MouseEventNote Addin
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
* * **/
var addin = function addinMouseEventNote (self) {
View
2  src/Note/Note.js
@@ -12,7 +12,7 @@ mod({
init : function initNote (m) {
/**
* Initializes the Note Addin
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
*/
var addin = function addinNote (self) {
View
2  src/Note/NoteCenter.js
@@ -12,7 +12,7 @@ mod({
init : function initNoteCenter (m) {
/**
* Initializes the NoteCenter Addin
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
*/
var addin = function addinNoteCenter (self) {
View
2  src/Note/NotePasser.js
@@ -13,7 +13,7 @@ mod({
init : function initNotePasser (m) {
/** * *
* Initializes the NotePasser Addin
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
* * **/
var defaultNoteCenter;
View
2  src/Utils/Assert.js
@@ -12,7 +12,7 @@ mod({
init : function initType (m) {
/** * *
* Initializes the assert object.
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
* * **/
//--------------------------------------
// ADDITIONS TO WINDOW
View
2  src/Utils/Pool.js
@@ -16,7 +16,7 @@ mod({
init : function initPool (m) {
/** * *
* Initializes the Pool Addin
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
* * **/
function createPond(type, create, init, recycle) {
/** * *
View
2  src/Utils/Utils.js
@@ -12,7 +12,7 @@ mod({
init : function initUtils (m) {
/** * *
* Initializes the utilities object.
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
* * **/
var utils = {};
View
2  src/View/View.js
@@ -1,6 +1,6 @@
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* View.js
-* The main view element.
+* The main view type.
* Copyright (c) 2012 Schell Scivally. All rights reserved.
*
* @author Schell Scivally
View
2  tests/BitmapTests.js
@@ -12,7 +12,7 @@ mod({
init : function initBitmapTests (m) {
/**
* Initializes the BitmapTests
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
*/
return function runBitmapTests(callback) {
var assert = m.assert;
View
2  tests/GeomTests.js
@@ -12,7 +12,7 @@
init : function initRectangleTests (m) {
/**
* Initializes the RectangleTests
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
*/
return function runGeomTests(callback) {
// aliases
View
2  tests/NoteTests.js
@@ -12,7 +12,7 @@ mod({
init : function initNoteCenterTests (m) {
/**
* Initializes the NoteCenterTests
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
*/
return function runNoteCenterTests(callback) {
// aliases
View
2  tests/SpriteTests.js
@@ -12,7 +12,7 @@ mod({
init : function initSpriteTests (m) {
/**
* Initializes the SpriteTests
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
*/
return function runSpriteTests(callback) {
View
2  tests/TextTests.js
@@ -12,7 +12,7 @@ mod({
init : function initTextTests (m) {
/**
* Initializes the TextTests
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
*/
// aliases
var ifndefInit = m.ifndefInit;
View
2  tests/UtilsTests.js
@@ -12,7 +12,7 @@ mod({
init : function initUtilsTests (m) {
/** * *
* Initializes the UtilsTests Addin
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
* * **/
return function runUtilsTests(callback) {
var assert = m.assert;
View
2  tests/VideoTests.js
@@ -12,7 +12,7 @@ mod({
init : function initVideoTests (m) {
/**
* Initializes the VideoTests
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
*/
return function(callback) {
View
2  tests/ViewTests.js
@@ -12,7 +12,7 @@ mod({
init : function initViewTests (m) {
/** * *
* Initializes the ViewTests
- * @param - m Object - The mod modules object.
+ * @param {Object} The mod modules object.
* * **/
return function runViewTests(callback) {
var assert = m.assert;
Please sign in to comment.
Something went wrong with that request. Please try again.