Twice PI.
Find the angle of a segment from (x1, y1) -> (x2, y2).
Find the angle of a segment from (x1, y1) -> (x2, y2).
The x coordinate of the first value.
The y coordinate of the first value.
The x coordinate of the second value.
The y coordinate of the second value.
The angle, in radians.
Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y).
Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y).
The first point.
The second point.
The angle between the two points, in radians.
Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y).
Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y).
The first point.
The second point.
The angle, in radians.
Find the angle of a segment from (x1, y1) -> (x2, y2).
Find the angle of a segment from (x1, y1) -> (x2, y2). The difference between this method and Math.angleBetween is that this assumes the y coordinate travels down the screen.
The x coordinate of the first value.
The y coordinate of the first value.
The x coordinate of the second value.
The y coordinate of the second value.
The angle, in radians.
Averages all values passed to the function and returns the result.
Averages all values passed to the function and returns the result.
The average of all given values.
Returns a number between the min
and max
values.
Returns a number between the min
and max
values.
The minimum value. Must be positive, and less than 'max'.
The maximum value. Must be position, and greater than 'min'.
A value between the range min to max.
A Bezier Interpolation Method, mostly used by Phaser.Tween.
A Bezier Interpolation Method, mostly used by Phaser.Tween.
The input array of values to interpolate between.
The percentage of interpolation, between 0 and 1.
The interpolated value
A Catmull Rom Interpolation Method, mostly used by Phaser.Tween.
A Catmull Rom Interpolation Method, mostly used by Phaser.Tween.
The input array of values to interpolate between.
The percentage of interpolation, between 0 and 1.
The interpolated value
Ceils to some place comparative to a base
, default is 10 for decimal place.
Ceils to some place comparative to a base
, default is 10 for decimal place.
The place
is represented by the power applied to base
to get that place.
The value to round.
The place to round to.
The base to round in. Default is 10 for decimal.
The rounded value.
Force a value within the boundaries by clamping it to the range min
, max
.
Force a value within the boundaries by clamping it to the range min
, max
.
The value to be clamped.
The minimum bounds.
The maximum bounds.
The clamped value.
Clamp x
to the range [a, Infinity)
.
Clamp x
to the range [a, Infinity)
.
Roughly the same as Math.max(x, a)
, except for NaN handling.
TODO
TODO
a number
Convert degrees to radians.
Convert degrees to radians.
Angle in degrees.
Angle in radians.
The absolute difference between two values.
The absolute difference between two values.
The first value to check.
The second value to check.
The absolute difference between the two values.
Returns the euclidian distance between the two given set of coordinates.
Returns the euclidian distance between the two given set of coordinates.
The x coordinate of the first value.
The y coordinate of the first value.
The x coordinate of the second value.
The y coordinate of the second value.
The distance between the two sets of coordinates.
Returns the distance between the two given set of coordinates at the power given.
Returns the distance between the two given set of coordinates at the power given.
The x coordinate of the first value.
The y coordinate of the first value.
The x coordinate of the second value.
The y coordinate of the second value.
optional: exponent
The distance between the two sets of coordinates.
Returns the euclidean distance squared between the two given set of coordinates (cuts out a square root operation before returning).
Returns the euclidean distance squared between the two given set of coordinates (cuts out a square root operation before returning).
The x coordinate of the first value.
The y coordinate of the first value.
The x coordinate of the second value.
The y coordinate of the second value.
The distance squared between the two sets of coordinates.
Computes the factorial of the given value
Computes the factorial of the given value
the number you want to evaluate
the factorial value
Floors to some place comparative to a base
, default is 10 for decimal place.
Floors to some place comparative to a base
, default is 10 for decimal place.
The place
is represented by the power applied to base
to get that place.
The value to round.
The place to round to.
The base to round in. Default is 10 for decimal.
The rounded value.
Applies a fuzzy ceil to the given value.
Applies a fuzzy ceil to the given value.
The value to ceil.
The epsilon (a small value used in the calculation)
ceiling(value - epsilon)
Two number are fuzzyEqual if their difference is less than epsilon.
Two number are fuzzyEqual if their difference is less than epsilon.
The first number to compare.
The second number to compare.
The epsilon (a small value used in the calculation)
True if | a-b | < epsilon
Applies a fuzzy floor to the given value.
Applies a fuzzy floor to the given value.
The value to floor.
The epsilon (a small value used in the calculation)
floor(value + epsilon)
a
is fuzzyGreaterThan b
if it is more than b - epsilon.
a
is fuzzyGreaterThan b
if it is more than b - epsilon.
The first number to compare.
The second number to compare.
The epsilon (a small value used in the calculation)
True if a > b + epsilon
a
is fuzzyLessThan b
if it is less than b + epsilon
.
a
is fuzzyLessThan b
if it is less than b + epsilon
.
The first number to compare.
The second number to compare.
The epsilon (a small value used in the calculation)
True if a < b + epsilon
Gets the shortest angle between angle1
and angle2
.
Gets the shortest angle between angle1
and angle2
.
Both angles must be in the range -180 to 180, which is the same clamped
range that sprite.angle
uses, so you can pass in two sprite angles to
this method, and get the shortest angle back between the two of them.
The angle returned will be in the same range. If the returned angle is
greater than 0 then it's a counter-clockwise rotation, if < 0 then it's
a clockwise rotation.
The first angle. In the range -180 to 180.
The second angle. In the range -180 to 180.
The shortest angle, in degrees. If greater than zero it's a counter-clockwise rotation.
Returns true if the number given is even.
Returns true if the number given is even.
The number to check.
True if the given number is even. False if the given number is odd.
Returns true if the number given is odd.
Returns true if the number given is odd.
The number to check.
True if the given number is odd. False if the given number is even.
Calculates a linear (interpolation) value over t.
Calculates a linear (interpolation) value over t.
number
number
A value between 0 and 1.
number
A Linear Interpolation Method, mostly used by Phaser.Tween.
A Linear Interpolation Method, mostly used by Phaser.Tween.
The input array of values to interpolate between.
The percentage of interpolation, between 0 and 1.
The interpolated value
Linear mapping from range to range
Linear mapping from range to range
The value to map
First endpoint of the range
Final endpoint of the range
First endpoint of the range
Final endpoint of the range
number
Variation of Math.max that can be passed either an array of numbers or the numbers as parameters.
Variation of Math.max that can be passed either an array of numbers or the numbers as parameters.
Prefer the standard Math.max
function when appropriate.
The largest value from those given.
Adds the given amount to the value, but never lets the value go over the specified maximum.
Adds the given amount to the value, but never lets the value go over the specified maximum.
The value to add the amount to.
The amount to add to the value.
The maximum the value is allowed to be.
The new value.
Variation of Math.max that can be passed a property and either an array of objects or the objects as parameters.
Variation of Math.max that can be passed a property and either an array of objects or the objects as parameters. It will find the largest matching property value from the given objects.
The largest value from those given.
Variation of Math.min that can be passed either an array of numbers or the numbers as parameters.
Variation of Math.min that can be passed either an array of numbers or the numbers as parameters.
Prefer the standard Math.min
function when appropriate.
The lowest value from those given.
Variation of Math.min that can be passed a property and either an array of objects or the objects as parameters.
Variation of Math.min that can be passed a property and either an array of objects or the objects as parameters. It will find the lowest matching property value from the given objects.
The lowest value from those given.
Subtracts the given amount from the value, but never lets the value go below the specified minimum.
Subtracts the given amount from the value, but never lets the value go below the specified minimum.
The base value.
The amount to subtract from the base value.
The minimum the value is allowed to be.
The new value.
Normalizes an angle to the [0,2pi) range.
Normalizes an angle to the [0,2pi) range.
The angle to normalize, in radians.
The angle, fit within the [0,2pi] range, in radians.
Work out what percentage value a
is of value b
using the given base.
Work out what percentage value a
is of value b
using the given base.
The value to work out the percentage for.
The value you wish to get the percentage of.
The base value.
The percentage a
is of b
, between 0
and 1
.
Convert radians to degrees.
Convert radians to degrees.
Angle in radians.
Angle in degrees
Reverses an angle.
Reverses an angle.
The angle to reverse, in radians.
The reverse angle, in radians.
Rotates currentAngle towards targetAngle, taking the shortest rotation distance.
Rotates currentAngle towards targetAngle, taking the shortest rotation distance. The lerp argument is the amount to rotate by in this call.
The current angle, in radians.
The target angle to rotate to, in radians.
The lerp value to add to the current angle.
The adjusted angle.
Round to the next whole number away from zero.
Round to the next whole number away from zero.
Any number.
The rounded value of that number.
Round to some place comparative to a base
, default is 10 for decimal place.
Round to some place comparative to a base
, default is 10 for decimal place.
The place
is represented by the power applied to base
to get that place.
The value to round.
The place to round to.
The base to round in. Default is 10 for decimal.
The rounded value.
Shear
Shear
a number
n mod 1
A value representing the sign of the value: -1
for negative, +1
for positive, 0
if value is 0
.
A value representing the sign of the value: -1
for negative, +1
for positive, 0
if value is 0
.
This works differently from Math.sign
for values of NaN
and -0
, etc.
a number
An integer in {-1, 0, 1}
Generate a sine and cosine table simultaneously and extremely quickly.
Generate a sine and cosine table simultaneously and extremely quickly. The parameters allow you to specify the length, amplitude and frequency of the wave. This generator is fast enough to be used in real-time. Code based on research by Franky of scene.at
The length of the wave
The amplitude to apply to the sine table (default 1.0) if you need values between say -/+ 125 then give 125 as the value
The amplitude to apply to the cosine table (default 1.0) if you need values between say -/+ 125 then give 125 as the value
The frequency of the sine and cosine table data
Returns the table data.
Smootherstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep
Smootherstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep
The input value.
The left edge. Should be smaller than the right edge.
The right edge.
A value between 0
and 1
.
Smoothstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep
Smoothstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep
The input value.
The left edge. Should be smaller than the right edge.
The right edge.
A value between 0
and 1
.
Snap a value to nearest grid slice, using rounding.
Snap a value to nearest grid slice, using rounding. Example: if you have an interval gap of 5 and a position of 12... you will snap to 10 whereas 14 will snap to 15.
The value to snap.
The interval gap of the grid.
Optional starting offset for gap.
The snapped value.
Snap a value to nearest grid slice, using ceil.
Snap a value to nearest grid slice, using ceil. Example: if you have an interval gap of 5 and a position of 12... you will snap to 15. As will 14 will snap to 15... but 16 will snap to 20.
The value to snap.
The interval gap of the grid.
Optional starting offset for gap.
The snapped value.
Snap a value to nearest grid slice, using floor.
Snap a value to nearest grid slice, using floor. Example: if you have an interval gap of 5 and a position of 12... you will snap to 10. As will 14 snap to 10... but 16 will snap to 15.
The value to snap.
The interval gap of the grid.
Optional starting offset for gap.
The snapped value.
Checks if two values are within the given tolerance of each other.
Checks if two values are within the given tolerance of each other.
The first number to check
The second number to check
The tolerance. Anything equal to or less than this is considered within the range.
True if a
is <= tolerance of b
.
Ensures that the value always stays between min
and max
, by wrapping the value around.
Ensures that the value always stays between min
and max
, by wrapping the value around.
If max
is not larger than min
the result is 0.
The value to wrap.
The minimum the value is allowed to be.
The maximum the value is allowed to be, should be larger than min
.
The wrapped value.
Keeps an angle value between -180 and +180; or -PI and PI if radians.
Keeps an angle value between -180 and +180; or -PI and PI if radians.
The angle value to wrap
Set to true if the angle is given in radians, otherwise degrees is expected.
Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around.
Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around. Values must be positive integers, and are passed through Math.abs. See Phaser.Math#wrap for an alternative.
The value to add the amount to.
The amount to add to the value.
The maximum the value is allowed to be.
The wrapped value.
A collection of useful mathematical functions. These are normally accessed through game.math.
io.scalajs.dom.html.phaser.utils.Utils
io.scalajs.dom.html.phaser.utils.ArrayUtils
https://phaser.io/docs/2.6.2/Phaser.Math.html