Farklı entegratörlerin artıları ve eksileri [kapalı]


29

Oyunlarda fizik gibi şeyler yaratırken bir entegratöre ihtiyacınız var. Verlet entegrasyonunun Euler entegrasyonuna harika bir alternatif olarak birçok yerden bahsettiğini gördüm. Örneğin , Thomas Jakobsen'in ünlü belgesinde . Ancak bu makalede Glenn Fiedler şöyle yazıyor:

Sizi varolan farklı entegratörlerin geniş yelpazesi ile tanıştırmak yerine, peşine düşeceğim ve en iyisine gideceğim. Bu entegratöre Runge Kutta sipariş 4 entegratörü aka RK4 denir.

Görünüşe göre gümüş mermi yok. Farklı entegratörlerin artıları ve eksileri nedir? Sadelik, hız, doğruluk, istikrar vb. İle ilgili olarak. Hangi entegratörler hangi oyun türleri için en uygundur? Ne zaman Verlet, RK4 veya başkalarını kullanırsınız? Hiç Euler kullanmalı mıydın?


There's an SO answer you might fancy stackoverflow.com/questions/2769466/…
teodron

Thanks for the link. I'm already aware of it though.
paldepind

Yanıtlar:


27

Pros and cons of both methods:

RK4 Pros:

  1. accuracy (thanks to its better approximation series it yields a 4th order precission)
  2. artificial/inherently induced damping (a bit like implicit methods do it) adds stability (whereas a simple Euler step doesn't - it does the opposite actually, introducing ghost energy that builds up and could plunge the system into chaos)

RK4 Cons:

  1. computation expense: while not that demanding in comparison to implicit methods or hybrid IMEX methods, RK4 is 4 times more expensive than the explicit Euler since it requires that many more function evaluations. This shows when aiming for the bleeding edge of optimization.
  2. still unstable: depending on the types of forces involved, RK4 can be just as unstable as Euler. On average, RK4 is a bit more stable and tends to draw this benefit from its endowed damping "skills".
  3. Belirsiz olmayan: sayısal sönümleme bir maliyetle gelir - enerji / hacim / vb. Sistemleri simüle edemezsiniz. Kayıp, zaman içerisinde görünür bir etki uygulamamalıdır (örneğin, Moleküler Dinamik, Potansiyel Alan kaynaklı kuvvetler, değişken problemler).

Verlet Artıları:

  1. Bir Euler adımının karmaşıklığının bir veya iki katı (Verlet lezzetinize bağlı olarak: konum veya hız).
  2. sempatik: iç enerjiyi korur
  3. ikinci derece doğruluk: birçok oyun yüksek hassasiyetli kayan nokta sonuçları gerektirmez ve ikinci derece bir oyun senaryosunda göze hoş gelmekten daha fazla bir şey değildir (artı: "keşfedildiğinde" oyun dışı bir senaryo simülasyonunda kullanılmıştır. o kadar da kötü değil)

Verlet Eksileri:

  1. stable, but still: probably the best explicit method in terms of stability. It tends to win the edge when hard constraints are added to the system, thus allowing for less head-aches when implementing projected constraints in position based dynamics engines. It sets off to infinity if the system is perturbed with large external forces and no damping/friction is added. Even so, there are certain numerically imposed limits to how large the internal (spring) forces can be, but they're higher on average than what RK4 can do
  2. lower accuracy: not useful if you want high precission estimations
  3. requires, on average, smaller time-steps than RK4 for some simulations (RK4 benefits from both its accuracy and internal damping)

Birini diğerinin üzerinde kullanmak, senaryoya göre değişir. Sertlik ve büyük dış kuvvetler ve sanal enerjiler bir sorunsa, açıklamalarında / başlıklarında "örtük" kelimesi bulunan diğer yöntemleri düşünün.


Bazı yazarların / kitapların, Verlet'in gerçekten türetildiği, sempatik Euler yöntemi (veya Euler Cromer) olarak adlandırılan gerçek bir açık Euler entegratörü için yarı-örtülü Euler terimini kullandığını unutmayın . Verlet, bazı insanlar tarafından "birdirbir" yöntemi olarak da adlandırılır. Velocity Verlet ve orta nokta yöntemi, bir zaman adımındaki bir tahminden beri oldukça benzerdir.t + 0.5*dtöngörücü-düzeltici benzeri adım için gereklidir. IMEX yöntemleri (örtük-açık), iki benzer fakat aynı olmayan yaklaşımı isimlendirmek için de kullanılır: hesaplamaları sert ve sert olmayan parçalara ayırmak ve üzerinde farklı entegratörler kullanmak (sert, katı olmayanlar için açık) VEYA Örtük bir güncelleme adımına sahip hız ve pozisyonu açık bir şekilde güncelleyin (bu, sert kısımlar hızlanma hesaplamasını en çok etkilediği için IMEX yöntemlerine düşen karma bir yarı yöntemdir). Örtük yöntemler daha zordur ve tüm konfigürasyon için eşzamanlı doğrusal olmayan denklem sistemlerinin çözülmesini gerektirir. Örtük yöntemler, deforme olabilen cisimler için kullanılır ve genellikle ayrışmış rijit cisimler için kullanılmaz.

As stated in one of the comments, if you can, do not use Euler. Use either the midpoint method, the semi-implicit Euler or, at the same expense, the position-Verlet. All of them have slightly higher accuracy and sensibly more stability than the explicit Euler integrator.

Recommended mini-comparison reading:

http://wiki.vdrift.net/Numerical_Integration


One observation: both Verlet variants can be coded to evaluate the acceleration only once per frame update.
teodron

1
Thanks for the answer! Pretty much what I was looking for.
paldepind

3

Euler implementations tend to be very fast, but far less stable than the alternatives. Runge Kutta is slower than Euler, but far more precise and stable.

I'm not very knowledgeable on Verlet integration, so i have no idea how it stacks up against Euler and Runge Kutta.

If you need your simulations to be more exact, or even numerically proof, Runge Kutta is the better of the two.

If you need fast, low cost physics for a simple game, Euler is the better choice.


2
Runge Kutta is by FAR NOT MORE STABLE THAN EULER. It's still Euler, done 8 times per frame instead of 1 (with a bit of prediction and correction but still..) forums.evilmana.com/game-programming-theory/…
teodron

2
Depends of what you need to be 'stable'. perhaps i should have elaborated, runge kutta is numerically more stable than euler. farside.ph.utexas.edu/teaching/329/lectures/node35.html
Timothy Groote

3
As far as I can figure out there's no reason why Verlet would be slower than Euler. So compared to Verlet Euler has no speed advantage and it's still much more precise and more stable. Hence I think your claim that Euler is best for a fast and simple physics is incorrect.
paldepind

4
Here is a blogpost showing the vast difference in accuracy: kahrstrom.com/gamephysics/2011/08/03/euler-vs-verlet
paldepind

2
In the last level of Transformers (PS2, 2004), the flight model I implemented used an Euler integrator which I updated 2000 times per frame. (Of course, it was a fairly realistic flight model being accelerated to supersonic speeds and placed inside a curved gravity field, so its requirements for stability were pretty intense. And there wasn't much else CPU-intensive going on in that level, so I was able to get away with it). Throwing extra iterations at Euler is often much easier than switching to a different iterator.
Trevor Powell

1

First and foremost I think you should use Euler until you experiance a direct need to use a more advanced integration scheme. It is fast and easy to implement.

If you experience stability issues such as systems of springs that never come to rest or if your simulation requires a high level of accuracy then start experimenting with the others.

One that I haven't seen mentioned above is the midpoint method which is very easy to implement and only requires one extra integration step.


1
I think Verlet is just a simple and easy to implement
paldepind

I've never used it myself but from what I understand you're probably correct.
Mikael Högström
Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.