or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

arrays.mdassertions.mdcore.mddom.mdevents.mdindex.mdmath.mdobjects.mdstrings.md
tile.json

math.mddocs/

Mathematical Operations

Mathematical utilities including basic functions, coordinate systems, geometric calculations, and range operations for computational and graphics applications.

Capabilities

Basic Math Functions

Core mathematical utility functions.

/**
 * Generates random integer from 0 to a-1
 * @param {number} a - Upper bound (exclusive)
 * @return {number} Random integer
 */
goog.math.randomInt = function(a) {};

/**
 * Generates uniform random number between a and b
 * @param {number} a - Lower bound
 * @param {number} b - Upper bound
 * @return {number} Random number between bounds
 */
goog.math.uniformRandom = function(a, b) {};

/**
 * Clamps value to specified range
 * @param {number} value - Value to clamp
 * @param {number} min - Minimum value
 * @param {number} max - Maximum value
 * @return {number} Clamped value
 */
goog.math.clamp = function(value, min, max) {};

/**
 * Modulo operation that handles negative numbers properly
 * @param {number} a - Dividend
 * @param {number} b - Divisor
 * @return {number} Modulo result
 */
goog.math.modulo = function(a, b) {};

/**
 * Linear interpolation between two values
 * @param {number} a - Start value
 * @param {number} b - End value
 * @param {number} x - Interpolation factor (0-1)
 * @return {number} Interpolated value
 */
goog.math.lerp = function(a, b, x) {};

/**
 * Tests if two numbers are nearly equal within tolerance
 * @param {number} a - First number
 * @param {number} b - Second number
 * @param {number=} opt_tolerance - Tolerance (default: 1e-6)
 * @return {boolean} True if nearly equal
 */
goog.math.nearlyEquals = function(a, b, opt_tolerance) {};

Angle Functions

Functions for working with angles and trigonometry.

/**
 * Standardizes angle to 0-360 degree range
 * @param {number} angle - Angle in degrees
 * @return {number} Standardized angle
 */
goog.math.standardAngle = function(angle) {};

/**
 * Standardizes angle to 0-2π radian range
 * @param {number} angle - Angle in radians
 * @return {number} Standardized angle
 */
goog.math.standardAngleInRadians = function(angle) {};

/**
 * Converts degrees to radians
 * @param {number} angleDegrees - Angle in degrees
 * @return {number} Angle in radians
 */
goog.math.toRadians = function(angleDegrees) {};

/**
 * Converts radians to degrees
 * @param {number} angleRadians - Angle in radians
 * @return {number} Angle in degrees
 */
goog.math.toDegrees = function(angleRadians) {};

/**
 * Calculates angle between two points
 * @param {number} x1 - First point X coordinate
 * @param {number} y1 - First point Y coordinate
 * @param {number} x2 - Second point X coordinate
 * @param {number} y2 - Second point Y coordinate
 * @return {number} Angle in degrees
 */
goog.math.angle = function(x1, y1, x2, y2) {};

/**
 * Calculates X component from angle and radius
 * @param {number} degrees - Angle in degrees
 * @param {number} radius - Radius
 * @return {number} X component
 */
goog.math.angleDx = function(degrees, radius) {};

/**
 * Calculates Y component from angle and radius
 * @param {number} degrees - Angle in degrees
 * @param {number} radius - Radius
 * @return {number} Y component
 */
goog.math.angleDy = function(degrees, radius) {};

Distance Functions

Functions for calculating distances and measurements.

/**
 * Calculates distance between two points
 * @param {number} x1 - First point X coordinate
 * @param {number} y1 - First point Y coordinate
 * @param {number} x2 - Second point X coordinate
 * @param {number} y2 - Second point Y coordinate
 * @return {number} Distance between points
 */
goog.math.distance = function(x1, y1, x2, y2) {};

/**
 * Calculates squared distance between two points (faster than distance)
 * @param {number} x1 - First point X coordinate
 * @param {number} y1 - First point Y coordinate
 * @param {number} x2 - Second point X coordinate
 * @param {number} y2 - Second point Y coordinate
 * @return {number} Squared distance between points
 */
goog.math.squaredDistance = function(x1, y1, x2, y2) {};

Coordinate Classes

Classes for representing points and coordinates.

/**
 * 2D coordinate/point class
 * @param {number=} opt_x - X coordinate (default: 0)
 * @param {number=} opt_y - Y coordinate (default: 0)
 * @constructor
 */
goog.math.Coordinate = function(opt_x, opt_y) {};

/**
 * X coordinate
 * @type {number}
 */
goog.math.Coordinate.prototype.x;

/**
 * Y coordinate
 * @type {number}
 */
goog.math.Coordinate.prototype.y;

/**
 * Creates copy of coordinate
 * @return {goog.math.Coordinate} Cloned coordinate
 */
goog.math.Coordinate.prototype.clone = function() {};

/**
 * Translates coordinate by specified amounts
 * @param {number} tx - X translation
 * @param {number} ty - Y translation
 * @return {goog.math.Coordinate} This coordinate for chaining
 */
goog.math.Coordinate.prototype.translate = function(tx, ty) {};

/**
 * 3D coordinate/point class
 * @param {number=} opt_x - X coordinate (default: 0)
 * @param {number=} opt_y - Y coordinate (default: 0)
 * @param {number=} opt_z - Z coordinate (default: 0)
 * @constructor
 */
goog.math.Coordinate3 = function(opt_x, opt_y, opt_z) {};

/**
 * X coordinate
 * @type {number}
 */
goog.math.Coordinate3.prototype.x;

/**
 * Y coordinate
 * @type {number}
 */
goog.math.Coordinate3.prototype.y;

/**
 * Z coordinate
 * @type {number}
 */
goog.math.Coordinate3.prototype.z;

Size and Rectangle Classes

Classes for representing dimensions and rectangular areas.

/**
 * Size class representing width and height
 * @param {number} width - Width value
 * @param {number} height - Height value
 * @constructor
 */
goog.math.Size = function(width, height) {};

/**
 * Width value
 * @type {number}
 */
goog.math.Size.prototype.width;

/**
 * Height value
 * @type {number}
 */
goog.math.Size.prototype.height;

/**
 * Creates copy of size
 * @return {goog.math.Size} Cloned size
 */
goog.math.Size.prototype.clone = function() {};

/**
 * Rectangle class with position and size
 * @param {number} x - X coordinate
 * @param {number} y - Y coordinate
 * @param {number} w - Width
 * @param {number} h - Height
 * @constructor
 */
goog.math.Rect = function(x, y, w, h) {};

/**
 * Left coordinate
 * @type {number}
 */
goog.math.Rect.prototype.left;

/**
 * Top coordinate
 * @type {number}
 */
goog.math.Rect.prototype.top;

/**
 * Width
 * @type {number}
 */
goog.math.Rect.prototype.width;

/**
 * Height
 * @type {number}
 */
goog.math.Rect.prototype.height;

/**
 * Tests if point is inside rectangle
 * @param {goog.math.Coordinate} coord - Point to test
 * @return {boolean} True if point is inside
 */
goog.math.Rect.prototype.contains = function(coord) {};

/**
 * Box class with top/right/bottom/left values
 * @param {number} top - Top value
 * @param {number} right - Right value
 * @param {number} bottom - Bottom value
 * @param {number} left - Left value
 * @constructor
 */
goog.math.Box = function(top, right, bottom, left) {};

/**
 * Top value
 * @type {number}
 */
goog.math.Box.prototype.top;

/**
 * Right value
 * @type {number}
 */
goog.math.Box.prototype.right;

/**
 * Bottom value
 * @type {number}
 */
goog.math.Box.prototype.bottom;

/**
 * Left value
 * @type {number}
 */
goog.math.Box.prototype.left;

Range Classes

Classes for representing numeric ranges.

/**
 * Numeric range class
 * @param {number} a - First endpoint
 * @param {number} b - Second endpoint
 * @constructor
 */
goog.math.Range = function(a, b) {};

/**
 * Start of range (minimum value)
 * @type {number}
 */
goog.math.Range.prototype.start;

/**
 * End of range (maximum value)
 * @type {number}
 */
goog.math.Range.prototype.end;

/**
 * Tests if value is in range
 * @param {number} value - Value to test
 * @return {boolean} True if in range
 */
goog.math.Range.prototype.contains = function(value) {};

/**
 * Set of numeric ranges
 * @param {...goog.math.Range} var_args - Initial ranges
 * @constructor
 */
goog.math.RangeSet = function(var_args) {};

/**
 * Adds range to set
 * @param {goog.math.Range} range - Range to add
 */
goog.math.RangeSet.prototype.add = function(range) {};

/**
 * Removes range from set
 * @param {goog.math.Range} range - Range to remove
 */
goog.math.RangeSet.prototype.remove = function(range) {};

Usage Examples:

// Basic math operations
var clamped = goog.math.clamp(value, 0, 100); // Clamp to 0-100
var interpolated = goog.math.lerp(start, end, 0.5); // 50% between start and end
var randomNum = goog.math.randomInt(10); // Random 0-9

// Coordinate manipulation
var point = new goog.math.Coordinate(10, 20);
point.translate(5, -3); // Move to (15, 17)

var distance = goog.math.distance(0, 0, point.x, point.y);

// Rectangle operations
var rect = new goog.math.Rect(0, 0, 100, 50);
var insideRect = rect.contains(new goog.math.Coordinate(25, 10)); // true

// Range operations
var range = new goog.math.Range(0, 100);
var inRange = range.contains(50); // true