# Khan/khan-exercises

Port parabola intuition 2 to use a custom answer type

1 parent 61053c9 commit 303348dd014432e87813d9acbd4860ec212937bc joelburget committed Aug 15, 2012
Showing with 40 additions and 13 deletions.
1. +40 −13 exercises/parabola_intuition_2.html
 @@ -66,22 +66,49 @@ graph.currParabola.plot( true ); -
-

focus x coordinate: 0

+
+
+

focus x coordinate: 0

-

focus y coordinate: 0.25

+

focus y coordinate: 0.25

-

directrix: y=-0.25

+

directrix: y=-0.25

+
- - - +
[A, X1, Y1]
+
+ var parab = graph.currParabola; + return parab.getLeadingCoefficient() === A && + parab.getVertexX() === X1 && + parab.getVertexY() === Y1; +
+
+ guess = guess.length ? guess : [1, 0, 0]; + var parab = graph.currParabola; + parab.update.apply(parab, guess); + redrawParabola(true); +
+
+ guess = guess.length ? guess : [1, 0, 0]; + + // Update the graph parabola so we can use its methods + // to get focus and directrix + var parab = graph.currParabola; + parab.update.apply(parab, guess); + + var fX = parab.getFocusX(), + fY = parab.getFocusY(), + dK = parab.getDirectrixK(); + \$("#focus-x-label").html("<code>" + fX + "</code>").tmpl(); + \$("#focus-y-label").html("<code>" + fY + "</code>").tmpl(); + \$("#directrix-label").html("<code>" + dK + "</code>").tmpl(); +