Cruithne... goes the asteroids?

What did you draw?
Post Reply
A Random Player
Posts: 523
Joined: Mon Jun 03, 2013 4:54 pm

Cruithne... goes the asteroids?

Post by A Random Player »

Code: Select all

import math
output = "Gravity Fun at TestTubeGames: [ForceG: -2,Qual: 1,Zoom: 1,xSet: 0,ySet: 0]"
asteroids = 15
mass = 1000
radius = 100
angleoffset = 15
actualangle = (-angleoffset+90) * 2*math.pi/360
vel = math.sqrt(mass/radius)
period = 2*math.pi*math.sqrt(radius**3/mass)
output = output + ", [x0: 0,y0: 0,vx: 0,vy: 0,t0: 0,who: 1,m: " + str(mass) + "]"
for a in range(asteroids):
 angle = 2*math.pi*a/asteroids
 output = output + ", [x0: " + str(radius * math.cos(angle)) + ",y0: " + str(radius * math.sin(angle)) + ",vx: " + str(vel * math.cos(angle + actualangle)) + ",vy: " + str(vel * math.sin(angle + actualangle)) + ",t0: " + str(period * a / asteroids) + ",who: 3,m: 0]"
print output
http://codepad.org/GhkIUaiS
Any particle launched with a certain velocity and a certain distance relative to a gravity source has the same semi-major axis, and the same orbital period, regardless of the direction it travels.

This code is named after the famous asteroid 3753 Cruithne, and its bean-shaped orbit.

Basic:

Code: Select all

Gravity Fun at TestTubeGames: [ForceG: -2,Qual: 1,Zoom: 1,xSet: 0,ySet: 0], [x0: 0,y0: 0,vx: 0,vy: 0,t0: 0,who: 1,m: 1000], [x0: 100.0,y0: 0.0,vx: 0.818457684354,vy: 3.05452566185,t0: 0.0,who: 3,m: 0], [x0: 91.3545457643,y0: 40.6736643076,vx: -0.494689214077,vy: 3.12334477467,t0: 13.2461176877,who: 3,m: 0], [x0: 66.9130606359,y0: 74.3144825477,vx: -1.72229985328,vy: 2.65210920125,t0: 26.4922353755,who: 3,m: 0], [x0: 30.9016994375,y0: 95.1056516295,vx: -2.65210920125,vy: 1.72229985328,t0: 39.7383530632,who: 3,m: 0], [x0: -10.4528463268,y0: 99.4521895368,vx: -3.12334477467,vy: 0.494689214077,t0: 52.9844707509,who: 3,m: 0], [x0: -50.0,y0: 86.6025403784,vx: -3.05452566185,vy: -0.818457684354,t0: 66.2305884386,who: 3,m: 0], [x0: -80.9016994375,y0: 58.7785252292,vx: -2.45755131261,vy: -1.99008581371,t0: 79.4767061264,who: 3,m: 0], [x0: -97.8147600734,y0: 20.7911690818,vx: -1.43564401526,vy: -2.81761002651,t0: 92.7228238141,who: 3,m: 0], [x0: -97.8147600734,y0: -20.7911690818,vx: -0.165500825251,vy: -3.15794386854,t0: 105.968941502,who: 3,m: 0], [x0: -80.9016994375,y0: -58.7785252292,vx: 1.13325896097,vy: -2.95224052668,t0: 119.21505919,who: 3,m: 0], [x0: -50.0,y0: -86.6025403784,vx: 2.2360679775,vy: -2.2360679775,t0: 132.461176877,who: 3,m: 0], [x0: -10.4528463268,y0: -99.4521895368,vx: 2.95224052668,vy: -1.13325896097,t0: 145.707294565,who: 3,m: 0], [x0: 30.9016994375,y0: -95.1056516295,vx: 3.15794386854,vy: 0.165500825251,t0: 158.953412253,who: 3,m: 0], [x0: 66.9130606359,y0: -74.3144825477,vx: 2.81761002651,vy: 1.43564401526,t0: 172.19952994,who: 3,m: 0], [x0: 91.3545457643,y0: -40.6736643076,vx: 1.99008581371,vy: 2.45755131261,t0: 185.445647628,who: 3,m: 0]
(Turn trails off)

Shows the beaniness a bit more:

Code: Select all

Gravity Fun at TestTubeGames: [ForceG: -2,Qual: 1,Zoom: 1,xSet: 0,ySet: 0], [x0: 0,y0: 0,vx: 0,vy: 0,t0: 0,who: 1,m: 1000], [x0: 100.0,y0: 0.0,vx: 1.58113883008,vy: 2.73861278753,t0: 0.0,who: 3,m: 0], [x0: 91.3545457643,y0: 40.6736643076,vx: 0.330548024243,vy: 3.14495437227,t0: 13.2461176877,who: 3,m: 0], [x0: 66.9130606359,y0: 74.3144825477,vx: -0.977197537924,vy: 3.00750477504,t0: 26.4922353755,who: 3,m: 0], [x0: 30.9016994375,y0: 95.1056516295,vx: -2.11597676822,vy: 2.35003027988,t0: 39.7383530632,who: 3,m: 0], [x0: -10.4528463268,y0: 99.4521895368,vx: -2.88888439225,vy: 1.28621419997,t0: 52.9844707509,who: 3,m: 0], [x0: -50.0,y0: 86.6025403784,vx: -3.16227766017,vy: 3.87254531519e-16,t0: 66.2305884386,who: 3,m: 0], [x0: -80.9016994375,y0: 58.7785252292,vx: -2.88888439225,vy: -1.28621419997,t0: 79.4767061264,who: 3,m: 0], [x0: -97.8147600734,y0: 20.7911690818,vx: -2.11597676822,vy: -2.35003027988,t0: 92.7228238141,who: 3,m: 0], [x0: -97.8147600734,y0: -20.7911690818,vx: -0.977197537924,vy: -3.00750477504,t0: 105.968941502,who: 3,m: 0], [x0: -80.9016994375,y0: -58.7785252292,vx: 0.330548024243,vy: -3.14495437227,t0: 119.21505919,who: 3,m: 0], [x0: -50.0,y0: -86.6025403784,vx: 1.58113883008,vy: -2.73861278753,t0: 132.461176877,who: 3,m: 0], [x0: -10.4528463268,y0: -99.4521895368,vx: 2.55833636801,vy: -1.8587401723,t0: 145.707294565,who: 3,m: 0], [x0: 30.9016994375,y0: -95.1056516295,vx: 3.09317430615,vy: -0.657474495161,t0: 158.953412253,who: 3,m: 0], [x0: 66.9130606359,y0: -74.3144825477,vx: 3.09317430615,vy: 0.657474495161,t0: 172.19952994,who: 3,m: 0], [x0: 91.3545457643,y0: -40.6736643076,vx: 2.55833636801,vy: 1.8587401723,t0: 185.445647628,who: 3,m: 0]
$1 = 100¢ = (10¢)^2 = ($0.10)^2 = $0.01 = 1¢ [1]
Always check your units or you will have no money!
User avatar
testtubegames
Site Admin
Posts: 1148
Joined: Mon Nov 19, 2012 7:54 pm

Re: Cruithne... goes the asteroids?

Post by testtubegames »

Huh, I'd never heard of Cruithne or bean-orbits before -- thanks for sharing that. Reminds me that one of the options I'd like to have in the new gravity sim is the ability to make the screen rotate, so you can track orbits like these easier. (You could lock it to the 'sun' and 'earth', and then they'd look stationary and Cruithne would draw the bean)

Looks neat even now, though. I like how in the second one, the asteroids kinda whip around the star.
User avatar
robly18
Posts: 413
Joined: Tue Jun 04, 2013 2:03 pm

Re: Cruithne... goes the asteroids?

Post by robly18 »

Yeah, it sounds like it would be a neat thing. Unfortunately, I have no clue how you'd be able to code it.
I'm sure there's a way, but the only thing I can think of sounds like it would be laggy as could be.
Convincing people that 0.9999... = 1 since 2012
User avatar
testtubegames
Site Admin
Posts: 1148
Joined: Mon Nov 19, 2012 7:54 pm

Re: Cruithne... goes the asteroids?

Post by testtubegames »

robly18 wrote:Yeah, it sounds like it would be a neat thing. Unfortunately, I have no clue how you'd be able to code it.
I'm sure there's a way, but the only thing I can think of sounds like it would be laggy as could be.
(Famous last words) Shouldn't actually be too bad. It'll take a lot of UI decisions -- to make it easy to select/deselect/choose which is the star, etc. But for display purposes, each object would just need one position correction each frame before it's displayed. And the orbit lines would draw based on that screen position. So (hopefully) there'd be no appreciable lag.
Post Reply