diff --git a/authors.textile b/authors.textile index a77bf55..6a0895c 100644 --- a/authors.textile +++ b/authors.textile @@ -12,6 +12,7 @@ _The following people are totally rad and awesome because they have contributed * Steven Reid _steven @ reidnorthwest . com_ * David Moulton _dave@themoultons.net_ * Sebastian Slomski _sebastian@simple-systems.org_ +* Aaron Weinberger _aw9994@cs.ship.edu_ * ...You! What are you waiting for? Check out the contributing section and get cracking! diff --git a/chapters/math/constants.textile b/chapters/math/constants.textile new file mode 100644 index 0000000..18462ba --- /dev/null +++ b/chapters/math/constants.textile @@ -0,0 +1,49 @@ +--- +layout: recipe +title: Math Constants +chapter: Math +--- + +h2. Problem + +You need to use common mathematical constants like pi or e. + +h2. Solution + +Use Javascript's Math object to provide commonly needed mathematical constants. + +{% highlight coffeescript %} +Math.PI +# => 3.141592653589793 + +# Note: Capitalization matters! This produces no output, it's undefined. +Math.Pi +# => + +Math.E +# => 2.718281828459045 + +Math.SQRT2 +# => 1.4142135623730951 + +Math.SQRT1_2 +# => 0.7071067811865476 + +# Natural log of 2. ln(2) +Math.LN2 +# => 0.6931471805599453 + +Math.LN10 +# => 2.302585092994046 + +Math.LOG2E +# => 1.4426950408889634 + +Math.LOG10E +# => 0.4342944819032518 + +{% endhighlight %} + +h2. Discussion + +For another example of how a math constant is used in a real world problem, refer to the 'Converting Radians and Degrees' section of this Math chapter. \ No newline at end of file