Mugen87 / yuka

JavaScript library for developing Game AI.
https://mugen87.github.io/yuka/
MIT License
1.1k stars 90 forks source link

need explanation for this formula #76

Closed mzvast closed 1 year ago

mzvast commented 1 year ago

As in this part in ArriveBehavior.

70 :            let speed = distance / deceleration;
71 : 
72 :            // make sure the speed does not exceed the max
73 : 
74 :            speed = Math.min( speed, vehicle.maxSpeed );

here in line 70 the unit of speed is m/s, the unit of distance is m, the unit of deceleration is m/(s^2). So in the aspect of units, left part we get m/s, however, right part gives s^2, which apparently not equal.

So, am I wrong anywhere? Thanks~

Mugen87 commented 1 year ago

The computation in line 70 is physically incorrect. It's just an aproximation. deceleration is not meter per second squared in this case but just undefined. The idea is to compute a decreased speed with a simple computation.

mzvast commented 1 year ago

So its meaning is similar to what the SLOW DOWN RADIUS as in this one 🤔

Mugen87 commented 1 year ago

This computation looks similar, yes.

Mugen87 commented 1 year ago

You can read more about Yuka's Arrive implementation in Programming Game AI by Example, Chapter 3 (Steering Behavior, Arrive).