Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
meganindya committed Jun 17, 2020
1 parent d176c4e commit c26df72
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions js/utils/mathutils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
/**
* @file This contains the encapsulation related to math operations.
* @author Walter Bender
*
* @copyright 2014-2020 Walter Bender
* @copyright 2020 Anindya Kundu
*
* @license
* This program is free software; you can redistribute it and/or modify it under the terms of
* the The GNU Affero General Public License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* You should have received a copy of the GNU Affero General Public License along with this
* library; if not, write to the Free Software Foundation, 51 Franklin Street, Suite 500 Boston,
* MA 02110-1335 USA.
*/

/**
* Utility class for managing math operations.
*
* @class
* @classdesc This is the prototype that encapsulates the ten math operations: random, one-of,
* modulus, square root, add, subtract, multiply, divide, eucleidean distance, and exponent.
*/
class MathUtility {
/**
* Returns a random integer in a range.
*
* @static
* @param a - preferably the minimum
* @param b - preferably the maximum
* @returns {Number}
Expand Down Expand Up @@ -39,6 +64,7 @@ class MathUtility {
/**
* Randomly returns either a or b.
*
* @static
* @param a
* @param b
* @returns {*}
Expand All @@ -50,6 +76,7 @@ class MathUtility {
/**
* Returns a modulo b.
*
* @static
* @param a
* @param b
* @returns {Number}
Expand All @@ -66,6 +93,7 @@ class MathUtility {
/**
* Square-roots a number.
*
* @static
* @param a
* @returns {Number}
* @throws {String} No square root error, NAN error
Expand All @@ -85,6 +113,7 @@ class MathUtility {
/**
* Adds a and b.
*
* @static
* @param a
* @param b
* @returns {Number|String}
Expand All @@ -103,6 +132,7 @@ class MathUtility {
/**
* Subtracts b from a.
*
* @static
* @param a
* @param b
* @returns {Number}
Expand All @@ -119,6 +149,7 @@ class MathUtility {
/**
* Multiplies a by b.
*
* @static
* @param a
* @param b
* @returns {Number}
Expand All @@ -135,6 +166,7 @@ class MathUtility {
/**
* Divides a by b.
*
* @static
* @param a
* @param b
* @returns {Number}
Expand All @@ -155,6 +187,7 @@ class MathUtility {
/**
* Calculates euclidean distance between (cursor x, cursor y) and (mouse 'x' and mouse 'y').
*
* @static
* @param a
* @param b
* @param c
Expand Down Expand Up @@ -182,6 +215,7 @@ class MathUtility {
/**
* Returns a to the power of b.
*
* @static
* @param a
* @param b
* @returns {Number}
Expand Down

0 comments on commit c26df72

Please sign in to comment.