Cannon.Math.Utils
y-lohse edited this page Jan 2, 2013
·
3 revisions
Contains a couple of utility math functions.
- min:Number : lower treshhold to use
- max:Number : upper treshhold to use
Computes a random value between 2 values (included)
- value:Number : hexadecimal value to convert
Converts a hexadecimal value into a decimal one
- value:Number : decimal value to convert
Converts a decimal value into a hexadecimal one
- value:Number : value to be converted
Converts a radian value into degrees
- value:Number : value to be converted
Converts a value in degrees into radians
- x1:Number
- y1:Number
- x2:Number
- y2:Number
- a:Point
- b:Point
Computes the distance between two points using Pythagora. Alternatively, the 2 first arguments can be points with x and y properties.
Both work :
Cannon.Utils.distance(0, 0, 10, 10);
and
Cannon.Utils.distance({x: 0, y: 0], {x: 10, y: 10});