![]() | ![]() ![]() ![]() |
This gem is about how you can approximate a quadratic/quadratic like curve with just adds. And this might come in handy some day. It is fast, and easy to set up.
To fully utilise this gem, we need a formula, so you can precalculate the needed add values. So imagine the standard quadratic equation:
f(x)=ax^2+bx+c=0Now, to calculate the two vaules we need for our addition, we need three points, with both
X and Y coordinates. Then we need to apply some mathematics to it (this is an example, approximating sin x): 0=a*0^2+b*0+c
1=a*(pi/2)^2+b*pi/2+c
0=a*pi^2+b*pi+cThis system can easily be solved using some kind of elemination. In my example these are the values I get: c=0
b=4/pi
a=4/pi^2Now, we can easily apply them in our formula:add ax,bx ; where ax=c, bx=a add bx,cx ; where cx=bIf you do more additions in your loop, you may "save" some additions by using the ADC-gem mentioned earlier.