Exp calculations are wack

trying to make accel curves for our robot. im trying to implement:

image

I have implemented this using:


    double position = 10;
    double expon = -0.075;
    int32_t input = 20;

    double output;
    double topExpon = expon * abs(double(input) - position);
    double botExpon = double(127) * expon;

    double top = 16129*(exp(topExpon) - (double)1);
    double bottom = 127*(exp(botExpon) - (double)1);

    output = (top / bottom);

when i run this standalone on my computer it outputs the proper expected value. however when I run the code on the vex v5 brain, it ouputs incorrectly.

I can not seem to figure out why this is happening other than the vex brain cannot do the calculations for some reason.

I have tried 127*(exp(botExpon) - (double)1) pre-calculated and used that. same result.

im honestly at a loss right now as what to do.

The code doesn’t compile (on a mac with clang), however.
This gives 67.0143 on both OSX and V5.

int main() {
    double position = 10;
    double expon = -0.075;
    int32_t input = 20;

    double output;
    double topExpon = expon * fabs((double)input - position);
    double botExpon = 127.0 * expon;

    double top = 16129*(exp(topExpon) - (double)1);
    double bottom = 127*(exp(botExpon) - (double)1);

    output = (top / bottom);
    
    printf("%3f\n", output);
}
2 Likes

ok im actually sped. I had the above code in a function exponential(double position, double expon, int32_t input) and when i was calling i was mixing up the position and expon arguements. it was never broken to begin with im just on smth.