Permalink
Browse files

Increase piFraction precision for areas of circles and sectors

  • Loading branch information...
1 parent bcd94c7 commit dc17a4fca6d053d33a17ad17f8b42e5901e0cd7a @osnr osnr committed Jul 11, 2012
Showing with 8 additions and 4 deletions.
  1. +2 −2 exercises/areas_of_circles_and_sectors.html
  2. +6 −2 utils/math-format.js
@@ -14,13 +14,13 @@
<var id="PRETTY_C">piFraction(C)</var>
<var id="S">ANGLE/360 * C</var>
- <var id="PRETTY_S">piFraction(S)</var>
+ <var id="PRETTY_S">piFraction(S, true, 0.0001)</var>
<var id="A_C">PI * R * R</var>
<var id="A_S">ANGLE/360 * A_C</var>
<var id="PRETTY_A_C">piFraction(A_C)</var>
- <var id="PRETTY_A_S">piFraction(A_S)</var>
+ <var id="PRETTY_A_S">piFraction(A_S, true, 0.0001)</var>
<var id="ROTATE_ARC">randRange(0, 359)</var>
</div>
View
@@ -143,9 +143,13 @@ $.extend(KhanUtil, {
* If niceAngle is truthy, it also delivers more natural values for 0 (0 instead
* of 0 \pi) and 1 (\pi instead of 1 \pi).
* */
- piFraction: function(num, niceAngle) {
+ piFraction: function(num, niceAngle, tolerance) {
if (num.constructor === Number) {
- var f = KhanUtil.toFraction(num / Math.PI, 0.001),
+ if (tolerance == null) {
+ tolerance = 0.001;
+ }
+
+ var f = KhanUtil.toFraction(num / Math.PI, tolerance),
n = f[0],
d = f[1];

0 comments on commit dc17a4f

Please sign in to comment.