2011-05-05 86 views
0

任何人都可以幫我用這條曲線的方程嗎?曲線方程

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; 
    } 
+0

wolframalpha.com – 2011-05-05 11:10:41

+0

這是不一致的 - 是 「Y」 代表 「位置」,或 「速度」? – Alnitak 2011-05-05 11:24:10

+0

velocity :) ... – clarkk 2011-05-05 11:25:08

回答

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> 
+0

我想看看這個函數的圖表,看看它是否像您要求的那樣是遠程的。 – Alnitak 2011-05-10 17:56:36

4

它看起來非常像從電子設備的標準的1/CR式電容器充電曲線,其從存儲器具有的公式:

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

因子「RC」(電阻*電容)對照斜坡接近漸近線的速度有多快。

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

曲線的形狀來自一個事實,即速率充電的(即一階導數)成比例的電流值與目標值之間的差

+0

是的,它可能看起來像一個4極高通濾波器..如果你知道任何關於音樂 – clarkk 2011-05-05 10:39:13

+0

@clarkk - 我這樣做,它不是一個適合濾波器轉換曲線的形狀。 – Alnitak 2011-05-05 10:47:25

+0

不,但它看起來像..但你能解釋更多的特定如何理解等式?對我來說這只是#!:) :) – clarkk 2011-05-05 10:50:00