Closed eonarheim closed 10 years ago
Definitely need angle helpers because I suck at math. Like toRadians(degrees)
and toDegrees(rad)
. Also move the getRandomIntInRange
method and add other rand helpers too I think.
Agreed.
Just had a thought, feel free to throw rocks at me, should we entertain the idea of boxed types for the different angle units like new ex.Radians(Math.PI)
and new ex.Degrees(180)
? Or is this level of verbosity more annoying than helpful?
Perhaps... thinking how would it look when passing those to canvas context. Maybe same frustration as color, where you always need to call Color.toString(). (Maybe enhancement to switch/add Color.fillStyle()
).
It does not look like we can create a module ex.Math{...}
without hiding the outer Math module in TypeScript. I am conceding for now and placing these into the ex.Util
module.
We have things that are not discoverable in ex.Util that probably belong in a math library:
canonicalizeAngle(angle)
randInRange(min, max)
clamp(val, min, max)
toRadians(degrees: number)
toDegrees(rads: number)
Possible ones for Algebra:
angleToPoint(source: ex.Point, dest: ex.Point)
pointOnLine(ray, distance)
pointOnCircle(origin, radius, vector, dist)