{
name: 'a * sqrt(1-(b^2/a^2))',
func: (a, b) -> a * Math.sqrt(1-((b*b)/(a*a)))
},
{
name: 'a',
func: (a, b) -> a
},
{
name: 'a - b',
func: (a, b) -> a - b
},
{
name: 'a^2 - b^2',
func: (a, b) -> a*a - b*b
},
{
name: 'a * cos(b/a)',
func: (a, b) -> a*Math.cos(b/a)
},
{
name: 'a * 2^(a-b) - a',
func: (a, b) -> a*Math.pow(2, (a-b))-a
},
]
for i in [0..@formulae.length-1]
@formulae[i].index=i
init_controls: () ->
@current_formula = 0
@current_steps = 10
@steps_values = [1..10]
$("#controls").append Mustache.to_html '''
<select id="steps_selector">
{{#steps_values}}
<option value="{{.}}">Approximation steps: {{.}}</option>
{{/steps_values}}
</select>
<select id="formula_selector">
{{#formulae}}
<option value="{{index}}">Formula: {{name}}</option>
{{/formulae}}
</select>
''', this
f_control= $("#formula_selector")
f_control.change () => @current_formula = f_control.val()
s_control= $("#steps_selector")
s_control.val(10)
s_control.change () => @current_steps = s_control.val()
start: () -> setInterval( (() => this.step()), 33)
step: () ->
@canvas.clear()
if ++@degree == 360 then @degree = 0
thick = .025
thin = .005
theta = @degree * 2 * PI / 360
x = Math.cos(theta)
y = Math.sin(theta)
@canvas.ctx.lineWidth = thin