folkarc:orbitalkit
This is an old revision of the document!
ORBITALKIT
Source
<file tcl> # ORBITALKIT - CC0 2023 Arcade Wise # Create a planet using “Claim $this is Earth” # Create a satellite using “Claim $this is a satellite”
proc orbitalVelocityAroundEarth {radius} {
set EarthMass [expr {5.972168 * (10 ** 18)}]
set G [expr {6.67430 * (10.0 ** (-11.0))}]
return [expr {sqrt(($G * $EarthMass) / $radius)}]
}
When /someone/ claims /earth_page/ is Earth {
When $earth_page has region /earth/ {
# Draw a little earth :>
lassign [region centroid $earth] x_earth y_earth
Display::circle $x_earth $y_earth 100 5 green
Wish $earth_page is labelled Earth
When /someone/ claims /sat_page/ is a satellite {
When $sat_page has region /sat/ & the clock time is /t/ & /sat/ has tag /tag/ {
set radius [vec2 distance [region centroid $earth] [region centroid $sat]]
# Display the orbit circle
Display::circle $x_earth $y_earth $radius 5 darkblue
set speed [orbitalVelocityAroundEarth [expr {$radius * 1000}]]
# Calculate postion for sattelite
set angle [expr {(round(($t * 200 + ($tag * 100))) % 2000) / 2000.0}]
set x [expr {($radius * sin(6.283 * $angle )) + $x_earth}]
set y [expr {($radius * cos(6.283 * $angle )) + $y_earth}]
# display the stroke
Display::stroke [list [region centroid $earth] [list $x $y]] 1 red
Display::circle $x $y 20 5 white true
Display::text $x [expr {$y - 40 }] 1 "[expr {round($speed)}]km/s at [expr {int($radius) * 1000}]km from Earth" [region angle $earth]
}
}
}
}
</code>
folkarc/orbitalkit.1696016329.txt.gz · Last modified: by discord
