曲线方程

时间:2011-05-05 10:26:13

标签: math

任何人都可以帮我解决这条曲线的等式吗?

http://temp.electrobeat.dk/eq.gif

I need to make an equation for an acceleration..
x = time
y = velocity (pixel)

constants:
t = time in ms when to recalculate the equation
m = max speed in pixels (y)
a = acceleration (how fast the curve rises)

编辑:

我在这里发现了一个有效的方程式,但我无法弄清楚每个参数的用途是什么?

Tween.regularEaseOut = function(t,b,c,d){
    return -c *(t/=d)*(t-2) + b;
    }

2 个答案:

答案 0 :(得分:4)

它看起来非常像电子产品的标准1 / CR型电容充电曲线,它从存储器中得到以下公式:

 (1 - e^(-t/RC))

因子“RC”(电阻*电容)控制斜率接近渐近线的速度。

参见例如http://jcsu.jesus.cam.ac.uk/~rpc25/notes/physics/capacitors/index.html

曲线的形状来自于电荷的速率(即一阶导数)与当前值和目标值之间的差值成比例的事实

答案 1 :(得分:0)

我明白了:)

<div id="tst" style="position:absolute; top:200px; left:200px; height:100px; width:100px; background:#ff0000"></div>

<script type="text/javascript">
    function Tween(){
        this.time = 0;
        this.begin = 200;
        this.change = 1000;
        this.duration = 800

        this.regularEaseInOut = function(t,b,c,d){
            if((t/=d/2) < 1){
                return c/2*t*t + b;
            }
            else{
                return -c/2 * ((--t)*(t-2) - 1) + b;
            }
        };
    }
    var Tween = new Tween();

    var int = 10;
    var loop = setInterval(function(){
        Tween.time += int;
        if(Tween.time >= Tween.duration){
            clearInterval(loop);
        }
        else{
            document.getElementById('tst').style.left = Tween.regularEaseInOut(Tween.time, Tween.begin, Tween.change, Tween.duration)+'px';
        }
    }, int);
</script>