[Haskell-cafe] Collision Detection

Yotam Ohad yotam2206 at gmail.com
Sat Jul 8 08:17:07 UTC 2017

Dear Cafe,
I am thinking about writing a small physics engine with collision detection
and I wanted to go over my ideas with you to help me refine them.

I want to express objects as a group of inequalities and their domain. For
example, a sphere would be only one inequality: x^2+y^2+z^2 -1 <= 0 on the
whole domain. That way, to check a collision between two objects, one needs
to check if at least one pair of inequalities with overlapping domains has
a solution. I am unsure about how to express the inequalities in a way that
could still allow me to compare between two of them.

To add forces in, I think I can express them by adding a time dimension to
the inequalities. For example, a constant force in the x-dimension on the
previous sphere could be represented as (C+dx/dt*t+0.5*a*t^2)^2+y^2+z^2 <=
0. But then I am not sure about how to treat non-integrable forces. Another
approach is to calculate the displacement of the object after each time
interval. I don't like this approach as I want to integrate it with FRP in
the end, and FRP continues time is something I would like to preserve.

After I'll have everything above sorted, the next things would be to run
simulations. I think at the start I'll check every pair of objects and try
to calculate whether or not the will collide in the future. I'll save all
the results in ascending time order. and every iteration, update the
movement after the closest collision and update the collision pair order.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170708/c157f230/attachment-0001.html>

More information about the Haskell-Cafe mailing list