I am trying to make an animation of the Sun-Earth-Moon system on Ursina with python by using Newton's law of gravitation with the sympletic integration. My problem is I don't know how to make the entities move by giving them positions at different times, I feel like you are only able to make them move by assigning each entity a function of time `
positons = [[ 0.00000000e+00 0.00000000e+00 -1.66774382e-01 9.69067588e-01
-4.35526765e-01 9.85610511e-01]
[ 0.00000000e+00 0.00000000e+00 -1.68497848e-01 9.68769962e-01
-4.37721005e-01 9.79750463e-01]
[-1.59474289e-12 9.16713058e-12 -1.70220804e-01 9.68469320e-01
-4.39790170e-01 9.73882842e-01]
...
[-2.27069908e-07 5.59350368e-07 -7.17772272e-01 6.76844085e-01
-6.36398380e-01 4.38107193e-01]
[-2.28638915e-07 5.62267372e-07 -7.18980419e-01 6.75586087e-01
-6.32080373e-01 4.39241274e-01]
[-2.30214659e-07 5.65190707e-07 -7.20186344e-01 6.74325991e-01
-6.27807854e-01 4.40505728e-01]]
` where each line is [sun_x,sun_y,earth_x,earth_y,moon_x,moon_y] and each column is for a different iteration (I used dt=0.1).
I don't know Ursina very well and can't find any documents that would help.`
from ursina import *
import numpy as np
`def update():
for entity in entities:`
entity.rotation_y += time.dt * 100
app = Ursina()
entities = []
sun = Entity(model='sphere', color=color.yellow, scale=1)
earth = Entity(parent=sun,model='sphere', color=color.blue,position=(-0.1667743823220, 0, 0.9690675883429), scale=0.4)
moon = Entity(parent=earth,model='sphere', color=color.white,position=(-0.1694619061456, 0, 0.9692330175719), scale=0.3)
entities.append(sun)
entities.append(earth)
entities.append(moon)
app.run()
I used this as a start but it doesn't show the real trajectory of the planets and is only time dependant, it is also using the 'parent' term which has no real physical/ astronomy meaning.
I'd like to find a way to code something like that :
def update():
earth.x=#the position x of the earth at a set time
earth.y=#the position y of the earth at a set time
moon.x=#the position x of the moon at a set time
moon.y=#the position y of the moon at a set time
maybe with a loop inside the update() to make them move for a set dt? Thank you for reading and helping!