I’ve made a very simple and primitive JavaScript canvas engine that is simply not dependent on time, as in it assumes that t = 1 in the formula v = u + at - v is the current velocity, u the initial velocity and a is acceleration due to gravity.

Now, the issue with this method is that if the value of gravity, or velocity is large enough that the object it should collide, it just goes right through it. Now, I have been told that if time was a parameter, we could just increase the frame rate and dilate the time to resolve this, but this would mean that the engine would no longer be deterministic - as in, the simulation would not work out the exact as it we assumed it to be, owing to hardware and software requirement like decimal point handling and precision.

How can we deal with this issue on this simple deterministic engine, and improve collision detection?

  • Breve@pawb.social
    link
    fedilink
    arrow-up
    5
    ·
    edit-2
    4 days ago

    I think you need to be more explicit about what you mean by “not dependent on time”. Setting t = 1 for that formula doesn’t eliminate time, it means you’re advancing time by 1 unit for every iteration of the formula defined by the units used to measure the velocity and acceleration (i.e. if v and u are measured in meters/second and a is meters/second^2 then t = 1 means you are modelling 1 second passing).

    If you mean deterministic as in there are no outside influences, instead you’d want to take the distance the object needs to travel before it hits something in it’s current trajectory then work backward to find out how much time it would take to cover that distance at the current velocity and acceleration.