I am trying to implement a parabolic function in Arduino.
The specs I want to create are:
starting point: [0,0]
middle point: [60,100]
end point: [120,0]
The function would be: (1/36)(-(X-60)^2)+100
When I add this function as an Arduino code:
((1/36)*((-pow(X-60,2))))+100;
It only gives the outcome: 100, when I print it..
What am I doing wrong?
The pow() function will bite you in the ass, too. It expects float arguments and produces a float output. Raising a value to a power of two using pow() is incredibly wasteful. A bit shift will be orders of magnitude faster, if the value is a integer. If not, simply multiplying by the value is faster.
Of course, you are storing an integer value in a float, so you will have problems deciding whether to treat seconds as an int or a float.