1. 2 months ago

    tomohaha3

    Oct 10 Sacramento, CA 94260A

    I'm looking to see if there's Math in Vex C++ as ROBOTC used to have it.
    I've no luck in finding "PI" and other mathematical constants and functions

  2. 9065_Parker

    Oct 10 Platte City Missouri 9065C
    Edited 2 months ago by 9065_Parker

    what are you trying to calculate?
    edit: you could just use 3.14159 as a replacement

  3. callen

    Oct 10 Braintree, MA, USA

    Pi isn't a standard in C++. There are various suggestions about the best approach. It is available in some libraries. But it's probably just easiest to make sure you write it properly and declare it globally yourself.

  4. OscarMNOVA12

    Oct 10 Event Partner, V5 Beta Tester Northern VA and Pittsburgh MASON, 12, 22172

    atan(1) * 4 = pi mathematically.

    The atan library is available.

    You could set that to a constant in the program.

  5. tomohaha3

    Oct 10 Sacramento, CA 94260A

    @9065_Parker what are you trying to calculate?

    I'm trying to get the circumference of the wheels and such. I'm also in need of calculating absolute values of numbers and finding square roots.

  6. jpearman

    Oct 10 Moderator, ROBOTC Tech Support, V5 Beta Moderator Los Angeles 8888

    @tomohaha3 I'm trying to get the circumference of the wheels and such. I'm also in need of calculating absolute values of numbers and finding square roots.

    We should be supporting all standard math functions.
    http://www.cplusplus.com/reference/cmath/

  7. jpearman

    Oct 10 Moderator, ROBOTC Tech Support, V5 Beta Moderator Los Angeles 8888
    Edited 2 months ago by jpearman

    Pi is defined as M_PI

    Brain.Screen.printAt(20, 20, "%f", M_PI );

    (which I should add is not really standard C but happens to be defined for now in VCS as it's part of math.h)

  8. callen

    Oct 11 Braintree, MA, USA

    @jpearman Pi is defined as M_PI
    (which I should add is not really standard C but happens to be defined for now in VCS as it's part of math.h)

    Ah, good to know it's not just standard C, that math.h is included. Thanks.

 

or Sign Up to reply!