Jump to content

Universal gravitation simulation


magbo

Recommended Posts

Hi, I came upon this awesome video by Sebastian Lague and was wondering how to do it in Houdini. In short, he makes a solar system sim by implementing the universal law of gravitation in code. I want to replicate the two planets "dancing" at the beginning.

I'm pretty new so please forgive me if my methods are noobie.

1. The first thing I tried was copying the code into an attribute wrangle but got stuck on how to mimic the loops he makes by each timestep to update the velocity and position.

2. Then I though it would be easier with POPs, and indeed just by using "pop axis force" one particle orbit was easily simulated. But I again got stuck when trying to do it with two particles, as I want to feedback each planet (particle) position so it can update the "pop axis force" 's centroid (this failed as the centroid is determined before the solver, so it doesn't update). Maybe looping by for each timestep? merging solvers? I'm lost and going nuts hahah.

 

How would you approach this? Thanks in advance!!

(Btw check Sebastian Lague channel, I'm pretty sure if you use Houdini you'll like what he makes.)

Link to comment
Share on other sites

links to have Fun ( In first link you have Nice ex how to read csv and other formats..(Python))and make visualization..and if you do a searching you can find A Ton of ex on JSON format reading into Houdini...
https://github.com/UTSDataArena/examples
http://bluevisual.tv/personal/shnops/
https://gist.github.com/olihawkins
https://github.com/kristinriebe/solarsystem-workshop..

..
regarding movement mass velocity and other stuff..
https://www.utas.edu.au/__data/assets/pdf_file/0006/415536/BenSimons.pdf
 

..use chops and you have in the first link how to read(for ex-- bacteria ..
Have Fun :wub:

  • Like 1
Link to comment
Share on other sites

Sebastian Lague's stuff is really cool - you have great taste.

His code can be translated pretty much directly into VEX; sqrMagnitude becomes length2(), normalized becomes normalize(), and the equivalent of timeStep is the @TimeInc attribute.

The key part is putting it inside a solver so the positions are updated each frame, based on their positions from the previous frame.

Here's my attempt:

nloug.thumb.gif.16ed2c279b98854be6c3f3f007ca4931.gif

(I'll post the file if you're still having trouble but it's a bit messy)

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...