goog.math
Namespacegoog.math.Bezier
ClassObject representing a cubic bezier curve. … more
goog.math.Box
ClassClass for representing a box. A box is specified as a top, right, bottom, and left. A box is useful for representing margins and padding. … more
goog.math.Coordinate
ClassClass for representing coordinates and positions. … more
goog.math.Coordinate3
ClassClass for representing coordinates and positions in 3 dimensions. … more
goog.math.ExponentialBackoff
Classgoog.math.Integer
ClassConstructs a two's-complement integer an array containing bits of the integer in 32-bit (signed) pieces, given in little-endian order (i.e., lowest-order bits in the first piece), and the sign of -1 or 0. See the from* functions below for other convenient ways of constructing Integers. The internal representation of an integer is an array of 32-bit signed pieces, along with a sign (0 or -1) that indicates the contents of all the other 32-bit pieces out to infinity. We use 32-bit pieces because these are the size of integers on which Javascript performs bit-operations. For operations like addition and multiplication, we split each number into 16-bit pieces, which can easily be multiplied within Javascript's floating-point representation without overflow or change in sign. … more
goog.math.Line
ClassObject representing a line. … more
goog.math.Long
ClassConstructs a 64-bit two's-complement integer, given its low and high 32-bit values as *signed* integers. See the from* functions below for more convenient ways of constructing Longs. The internal representation of a long is the two given signed, 32-bit values. We use 32-bit pieces because these are the size of integers on which Javascript performs bit-operations. For operations like addition and multiplication, we split each number into 16-bit pieces, which can easily be multiplied within Javascript's floating-point representation without overflow or change in sign. In the algorithms below, we frequently reduce the negative case to the positive case by negating the input(s) and then post-processing the result. Note that we must ALWAYS check specially whether those values are MIN_VALUE (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as a positive number, it overflows back into a negative). Not handling this case would often result in infinite recursion. … more
goog.math.Matrix
ClassClass for representing and manipulating matrices. The entry that lies in the i-th row and the j-th column of a matrix is typically referred to as the i,j entry of the matrix. The m-by-n matrix A would have its entries referred to as: [ a0,0 a0,1 a0,2 ... a0,j ... a0,n ] [ a1,0 a1,1 a1,2 ... a1,j ... a1,n ] [ a2,0 a2,1 a2,2 ... a2,j ... a2,n ] [ . . . . . ] [ . . . . . ] [ . . . . . ] [ ai,0 ai,1 ai,2 ... ai,j ... ai,n ] [ . . . . . ] [ . . . . . ] [ . . . . . ] [ am,0 am,1 am,2 ... am,j ... am,n ] … more
goog.math.Range
ClassA number range. … more
goog.math.RangeSet
ClassConstructs a new RangeSet, which can store numeric ranges. Ranges are treated as half-closed: that is, they are exclusive of their end value [start, end). New ranges added to the set which overlap the values in one or more existing ranges will be merged. … more
goog.math.Rect
ClassClass for representing rectangular regions. … more
goog.math.Size
ClassClass for representing sizes consisting of a width and height. Undefined width and height support is deprecated and results in compiler warning. … more
goog.math.Vec2
ClassClass for a two-dimensional vector object and assorted functions useful for manipulating points. … more
goog.math.Vec3
ClassClass for a three-dimensional vector object and assorted functions useful for manipulation. Inherits from goog.math.Coordinate3 so that a Vec3 may be passed in to any function that requires a Coordinate. … more
.angle(x1, y1, x2, y2)
Computes the angle between two points (x1,y1) and (x2,y2). Angle zero points in the +X direction, 90 degrees points in the +Y direction (down) and from there we grow clockwise towards 360 degrees.
x1
{number
}
y1
{number
}
x2
{number
}
y2
{number
}
number
}
.angleDifference(startAngle, endAngle)
Computes the difference between startAngle and endAngle (angles in degrees).
startAngle
{number
}
endAngle
{number
}
number
}
.angleDx(degrees, radius)
For a given angle and radius, finds the X portion of the offset.
degrees
{number
}
radius
{number
}
number
}
.angleDy(degrees, radius)
For a given angle and radius, finds the Y portion of the offset.
degrees
{number
}
radius
{number
}
number
}
.average(var_args)
Returns the arithmetic mean of the arguments.
var_args
{...number
}
number
}
.clamp(value, min, max)
Takes a number and clamps it to within the provided bounds.
value
{number
}
min
{number
}
max
{number
}
number
}
goog.math.interpolator
Namespace.isFiniteNumber(num)
Returns whether the supplied number is finite and not NaN.
num
{number
}
boolean
}
.isInt(num)
Returns whether the supplied number represents an integer, i.e. that is has no fractional component. No range-checking is performed on the number.
num
{number
}
boolean
}
.lerp(a, b, x)
Performs linear interpolation between values a and b. Returns the value between a and b proportional to x (when x is between 0 and 1. When x is outside this range, the return value is a linear extrapolation).
a
{number
}
b
{number
}
x
{number
}
number
}
.longestCommonSubsequence(array1, array2, opt_compareFn, opt_collectorFn)
JavaScript implementation of Longest Common Subsequence problem. http://en.wikipedia.org/wiki/Longest_common_subsequence Returns the longest possible array that is subarray of both of given arrays.
array1
{Array
.<Object
>}
array2
{Array
.<Object
>}
opt_compareFn
{Function
=}
opt_collectorFn
{Function
=}
Array
.<Object
>}
.modulo(a, b)
The % operator in JavaScript returns the remainder of a / b, but differs from some other languages in that the result will have the same sign as the dividend. For example, -1 % 8 == -1, whereas in some other languages (such as Python) the result would be 7. This function emulates the more correct modulo behavior, which is useful for certain applications such as calculating an offset index in a circular list.
a
{number
}
b
{number
}
number
}
.nearlyEquals(a, b, opt_tolerance)
Tests whether the two values are equal to each other, within a certain tolerance to adjust for floating pount errors.
a
{number
}
b
{number
}
opt_tolerance
{number
=}
boolean
}
.randomInt(a)
Returns a random integer greater than or equal to 0 and less than {@code a}.
a
{number
}
number
}
.sign(x)
Returns the sign of a number as per the "sign" or "signum" function.
x
{number
}
number
}
.standardAngle(angle)
Standardizes an angle to be in range [0-360). Negative angles become positive, and values greater than 360 are returned modulo 360.
angle
{number
}
number
}
.standardDeviation(var_args)
Returns the sample standard deviation of the arguments. For a definition of sample standard deviation, see e.g. http://en.wikipedia.org/wiki/Standard_deviation
var_args
{...number
}
number
}
.sum(var_args)
Returns the sum of the arguments.
var_args
{...number
}
number
}
goog.math.tdma
Namespace.toDegrees(angleRadians)
Converts radians to degrees.
angleRadians
{number
}
number
}
.toRadians(angleDegrees)
Converts degrees to radians.
angleDegrees
{number
}
number
}
.uniformRandom(a, b)
Returns a random number greater than or equal to {@code a} and less than {@code b}.
a
{number
}
b
{number
}
number
}