Skip to content

Commit aa81c4c

Browse files
author
Sebastian Slomski
committed
Merge pull request #9 from AaronW/master
Adding name to authors file.
2 parents 9034841 + 39aeb47 commit aa81c4c

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

authors.textile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ _The following people are totally rad and awesome because they have contributed
1212
* Steven Reid _steven @ reidnorthwest . com_
1313
* David Moulton _dave@themoultons.net_
1414
* Sebastian Slomski _sebastian@simple-systems.org_
15+
* Aaron Weinberger _aw9994@cs.ship.edu_
1516
* ...You! What are you waiting for? Check out the <a href="/contributing">contributing</a> section and get cracking!
1617

1718

chapters/math/constants.textile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
layout: recipe
3+
title: Math Constants
4+
chapter: Math
5+
---
6+
7+
h2. Problem
8+
9+
You need to use common mathematical constants like pi or e.
10+
11+
h2. Solution
12+
13+
Use Javascript's Math object to provide commonly needed mathematical constants.
14+
15+
{% highlight coffeescript %}
16+
Math.PI
17+
# => 3.141592653589793
18+
19+
# Note: Capitalization matters! This produces no output, it's undefined.
20+
Math.Pi
21+
# =>
22+
23+
Math.E
24+
# => 2.718281828459045
25+
26+
Math.SQRT2
27+
# => 1.4142135623730951
28+
29+
Math.SQRT1_2
30+
# => 0.7071067811865476
31+
32+
# Natural log of 2. ln(2)
33+
Math.LN2
34+
# => 0.6931471805599453
35+
36+
Math.LN10
37+
# => 2.302585092994046
38+
39+
Math.LOG2E
40+
# => 1.4426950408889634
41+
42+
Math.LOG10E
43+
# => 0.4342944819032518
44+
45+
{% endhighlight %}
46+
47+
h2. Discussion
48+
49+
For another example of how a math constant is used in a real world problem, refer to the <a href="http://coffeescriptcookbook.com/chapters/math/radians-degrees">'Converting Radians and Degrees'</a> section of this Math chapter.

0 commit comments

Comments
 (0)