3 ms·
Shameless plug: Accurate solar system in 192 Bytes: https://www.dwitter.net/d/26521 https://www.dwitter.net/d/26521 The red bit is the sun. 1000 kilometers pe
by tomxor 1y ago
Shameless plug: Accurate solar system in 192 Bytes:
https://www.dwitter.net/d/26521 https://www.dwitter.net/d/26521
The red bit is the sun. 1000 kilometers per pixel, and 1000 seconds per second.
They all fit onto the screen by looking through the orbital plane, as if through a telescope from a distant world, i.e effectively an orthographic projection. The orbits are accurate in terms of mean orbital distance (in reality there is slight perturbance) and sidereal periods.
- darajava 1y agoIncredible - how does this work?
- tomxor 1y agoYou mean technically? I should have posted the beta dwitter link which has the "compress" toggle, because most dweets are unicode packed. https://beta.dwitter.net/d/26521 https://beta.dwitter.net/d/26521 Here's the js anyway: for(i=10;i--;x.fillStyle=R(i-8||255),x.beginPath(x.fill()))x.arc(960+[45,29,14,8,2,1.5,1,.6,0,0][i]*1e5*S(t/5e3/[165,84,29,12,2,1,.6,.2,1,1][i]),540,[24,25,58,69,3.4,6.4,6,2.4,696,2e3][i],0,7) This one is actually relatively simple to explain, it loops over the 10 planets (i), and draws a circle for each, with the position and size all being defined in the x.arc method. Planets are differentiated by the arrays of values selected by [i]. The X position is calculated as the orbital distance multiplied by the sine of time / orbital period... d x sin(t/p). But d and p are substituted for the value for each planet using the arrays [1,2,3][i]. Surprisingly the precision used in those encoded values is enough at 1000km per pixel (I checked).
- ByThyGrace 1y agoI presume including Pluto's parameters in the array is both a rebellious statement and a brag. ("Yes, my JS snippet could have been even shorter if you asked the IAU.")
- tomxor 1y agoActually I couldn't fit Pluto, I sacrificed everything I could, but to fit it would require sacrificing the precision of Mars, Earth and Mercury (dropping the decimal), but I wanted to maintain enough precision to be able to tell them apart by size (which you just about can at full screen due to antialiasing)... Otherwise I definitely would have included it for that very sentiment ;) The reason there are 10 radi is for 8 planets + sun + drawing the black backdrop (2e3): [24,25,58,69,3.4,6.4,6,2.4,696,2e3]