# Test your math

**URL:** https://forum.kirupa.com/t/test-your-math/196712
**Category:** flash
**Created:** [August 10, 2006, 1:31pm UTC](https://forum.kirupa.com/t/test-your-math/196712 "2006-08-10T13:31:40Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tolk](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/tolk/32/2496_2.png) [@tolk](https://forum.kirupa.com/u/tolk)
#### Post date: [August 10, 2006, 1:31pm UTC](https://forum.kirupa.com/t/test-your-math/196712/1 "2006-08-10T13:31:40Z")

</div>

I’m using this as to work out positions on a bezier cubic curve:

```auto
t = Math.min(Math.max((position/total),0),1);
    
    var cx = 3* (control1.x - begin.x);
    var bx = 3* (control2.x - control1.x) - cx;
    var ax = end.x - begin.x - cx - bx;
    var zx = ax*t*t*t + bx*t*t + cx*t + begin.x;

    var cy = 3* (control1.y - begin.y);
    var by = 3* (control2.y - control1.x) - cy;
    var ay = end.y - begin.y - cy - by;
    var zy = ay*t*t*t + by*t*t + cy*t +begin.y;

```

Where zx,zy are the final position. Position is the step in the curve and total is the total number of steps in the curve.  
It’s working fine with posotive values but it messes up a bit with negative values. I’m tierd of looking at it, and tierd anyway. Can anyone see why it doesn’t work for negative values?  
Thanks!
