excaliburjs / Excalibur

🎮 Your friendly TypeScript 2D game engine for the web 🗡️
https://excaliburjs.com
BSD 2-Clause "Simplified" License
1.76k stars 188 forks source link

Add a ex.Math Library #281

Closed eonarheim closed 10 years ago

eonarheim commented 10 years ago

We have things that are not discoverable in ex.Util that probably belong in a math library:

Possible ones for Algebra:

kamranayub commented 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.

eonarheim commented 10 years ago

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?

kamranayub commented 10 years ago

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()).

eonarheim commented 10 years ago

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.