1

I'm not the best at Arduino so I'm sorry for my "noobiness".

I'm extending some code that I found online to work on the gyroscope that I'm building.

I'm wondering what the difference is between pow and sqrt in this code.

I'm also wondering what the 180/pi is used for. I haven't gotten my mind around this part yet.

arx = (180/3.141592) * atan(ax / pow((ay, 2) + pow(az, 2)); 

What's the difference here?

ary = (180/3.141592) * atan(ay / sqrt(square(ax, 2) + square(az, 2)));
4
  • 1
    pow(x, 2) is the second power, so x² or x*x. sqrt(x) is the square root of x, so $\sqrt x$. A whole circle is 360 degrees or 2π when measuring in radians. So this ratio of 180/3.141592 is used to convert an angle in radians to an angle in degrees.
    – Gerben
    Commented Oct 19, 2015 at 12:16
  • @Gerben That should be an answer, n'est pas? Commented Oct 19, 2015 at 16:13
  • @Gerben Do you know why im getting this error? In function 'void loop()': error: too few arguments to function 'double pow(double, double)' GettingValues:41: error: at this point in file error: too many arguments to function 'double square(double)' GettingValues:42: error: at this point in file error: too many arguments to function 'double square(double)'
    – Marc
    Commented Oct 20, 2015 at 7:40
  • 1
    Your parentheses are wrong. Change pow(( to pow(.
    – Gerben
    Commented Oct 20, 2015 at 8:35

1 Answer 1

1

Converting Gerben's comment into an answer:


pow(x, 2) is the second power, in other words:

x squared


sqrt(x) is the square root of x, that is:

Square root of x


A whole circle is 360 degrees or 2π when measuring in radians. So this ratio of 180 / 3.141592 is used to convert an angle in radians to an angle in degrees.

radians to degrees

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.