
Show HN: Dyna-Kinematics – A 2D physics simulator with some unique features - diegomacario
https://github.com/diegomacario/Dyna-Kinematics
======
diegomacario
Hi everyone!

I'm the author of this project. I wrote it because I was very curious about
physics simulation, and also because I wanted a reason to study a few
libraries that I had never worked with like Qt.

In the readme I tried to explain all the details of how the simulator works.
If you don't have time to read it, at least take a look at the GIFs in it.
They showcase everything that the simulator can do.

~~~
jessedhillon
There might be a really useful related application here. If I could set up a
2D scene to be simulated headlessly, apply forces programmatically, and then
receive the x position of an actor as an output, then this could be useful for
simulating complex UI behaviors.

For example, recently I wanted to create a scrolling behavior with boundaries
based on properties of the content. In this case, I wanted to draw a column of
cards with a bit of tension to overcome before flipping to the next card.

See this diagram: [https://imgur.com/a/zVvwtEu](https://imgur.com/a/zVvwtEu)

If the viewport was a physical actor in a simulation, gliding along a track
that I could generate based on the content, then the left edge of the actor
could control the scrollTop or drive the translateY of the content, etc.

Just wanted to share a possible application of your awesome work.

~~~
diegomacario
That's a really cool idea!

It's funny that you mention this because when I simulated the blocks hitting
the words "Dyna-Kinematics" for the title GIF I thought: "This is what graphic
designers struggle to do manually. They spend hours animating things so that
they look natural."

If graphic designers had access to a physics simulator, they wouldn't have to
do anything manually. They could just let the physics do the talking.

I really love that idea, and I think it would sell.

------
gmurphy
This is great! One very naive (I'm trying to learn) question:

You have a fixed timestep for good reason, which works great if you're
displaying by doing interpolation (your display frames lag the physics and are
'catching up' to them), but in some cases where you want low latency in
response to player input you might want extrapolation (your display frames are
ahead of the physics engine).

I believe people typically do extrapolation by projecting forward any motion
in a linear fashion, but it seems this would result in occasional weirdness
like geometry intersection. One solution might be to run the physics engine at
a fixed timestep for the 'real' changes, but let the graphics engine use the
physics engine at a non-fixed timestep to do the extrapolation, where the
results of that simulation are not taken into account for the fixed timestep
frames.

Is that possible in Dyna-Kinematics, and/or am I talking nonsense? :)

------
waltbosz
Did anyone else spend hours of their childhood playing The Incredible Machine
? Anytime I read about a 2D physics simulator, I can't help but think of that
game.

~~~
StavrosK
Oh man, TIM was such a fantastic game. I have great memories of endless fun in
it.

~~~
waltbosz
I forgot that the binary was named tim.exe

------
bsenftner
Does the Visual Studio project require QT be pre-installed? I don't see libs
or headers in the dependencies, and I don't have QT on my dev system. So the
project does not compile.

------
prox
Fun and informative, a great combination!

~~~
diegomacario
Thank you! That's exactly what I was going for :-)

------
chrisbennet
This is really awesome!

------
Karmic_Clash
Looks very cool!

~~~
diegomacario
Thank you! :-)

