這次換我有問題了XD
基本上是這樣的,我在寫一段程式碼,要模擬一顆球在碗裡移動.假設沒有滾動,但有摩擦力.那理論上來說過一陣子,球就會靜止停在碗底.
我這樣推公式的:
Assuming that the "bowl" look like y=x^2
a=g(-sin(tan^-1 (dy/dx))-\mu_k cos(tan^-1(dy/dx))*v/|v|)
This First part is the gravity "drive", and the second part is the frictional force part. the v/|v| is to make sure that the frictional force is acting against the direction of velocity.
With a in mind, we could - to first approximation,
v(t)=a(t-1)*time(t)+v(t-1)
x(t)=0.5*v(t)*time(t)+0.5*v(t-1)*t+x(t-1)
但這是我跑出來的結果:
t x v a
1 0.100000 0.500000 -6.864065
2 0.512719 -0.872813 -3.668453
3 -1.092503 -1.973349 11.173711
4 -4.539974 2.496136 9.392545
5 3.498467 7.192408 -10.606819
6 25.324187 0.828317 -10.096752
7 26.039503 -6.239409 -9.902167
8 -4.582591 -14.161143 10.483327
9 -70.434501 -4.726148 10.035241
10 -91.410695 5.309093 9.972502
11 -53.257318 16.278845 9.952619
12 61.348947 28.221989 -10.040417
13 254.652016 15.169446 -10.009798
14 361.647149 1.155729 -10.006903
15 359.924149 -13.854626 -9.993044
16 225.212345 -29.843497 -9.988875
17 -68.258279 -46.824585 10.036356
18 -515.562769 -28.759143 10.004844
19 -798.037065 -9.749938 10.003131
20 -885.280126 10.256323 9.997174
大家可以看的出來,這是越甩越遠...
我現在不是很確定哪邊出問題了...
這是cos(atan(dy/dx), -sin(atan(dy/dx)) 看起來數字正負號很正確
0.049938 0.998752
0.055470 0.998460
0.062378 0.998053
0.071247 0.997459
0.083046 0.996546
0.099504 0.995037
0.124035 0.992278
0.164399 0.986394
0.242536 0.970142
0.447214 0.894427
1.000000 -0.000000
0.447214 -0.894427
0.242536 -0.970142
0.164399 -0.986394
0.124035 -0.992278
0.099504 -0.995037
0.083046 -0.996546
0.071247 -0.997459
0.062378 -0.998053
0.055470 -0.998460
0.049938 -0.998752
難道問題出在滾動?
[ 這篇文章被編輯過: millitiz 在 2014-11-20 16:18:00 ]
[ 這篇文章被編輯過: millitiz 在 2014-11-20 16:37:39 ]