/p5.Math.js

The convenience Math methods from Processing implemented in Javascript

Primary LanguageJavaScript

Javascript implementation of the following Processing convenience methods declared in http://www.google.com/codesearch/p?hl=en#Ej56LtI_pY0/trunk/processing/core/methods/demo/PApplet.java

p5.sq()
p5.constrain()
p5.degrees()
p5.mag()
p5.dist()
p5.lerp()
p5.norm()
p5.map()

Very small in size, probably better to copy the minified version into your project, rather than linking to it.

Added optional extensions to the main Math object:

Math.sq()
Math.constrain()
Math.degrees()
Math.mag()
Math.dist()
Math.lerp()
Math.norm()
Math.map()

This code is not checking whether the methods already exist, use it at your own peril.

Note: Math does not get constructed and instantiated, but rather initialized. Adding methods with Math.prototype.myMethod does not work, rather use Math.myMethod