Accrete goes the asteroids

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

Accrete goes the asteroids

Post by A Random Player »

Code: Select all

import math
import random
output = "Gravity Fun at TestTubeGames: [ForceG: -2,Qual: 1,Zoom: 1,xSet: 0,ySet: 0]"
asteroids = 50
mass = 9001
output = output + ", [x0: 0,y0: 0,vx: 0,vy: 0,t0: 0,who: 2,m: " + str(mass) + ",c: 1]"
for a in range(asteroids):
 angle = random.random()*math.pi*2
 radius = random.random()*120+20
 vel = math.sqrt(mass/radius)
 output = output + ", [x0: " + str(radius * math.cos(angle)) + ",y0: " + str(radius * math.sin(angle)) + ",vx: " + str(vel * math.cos(angle + math.pi/2)) + ",vy: " + str(vel * math.sin(angle + math.pi/2)) + ",t0: 0,who: 2,m: 2,c: 2]"
print output
http://codepad.org/zPXYcbO2

I was going to post this but apparently I forgot. Generate your own protoplanetary disks, let systems form.
Small:

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: 2,m: 9001,c: 1], [x0: 122.259886277,y0: -37.3343319769,vx: 2.45068883916,vy: 8.02534618702,t0: 0,who: 2,m: 2,c: 2], [x0: 33.8607132316,y0: 52.0316152636,vx: -10.0923590358,vy: 6.56782368586,t0: 0,who: 2,m: 2,c: 2], [x0: -21.551202723,y0: 97.5391978016,vx: -9.26894976721,vy: -2.04796656077,t0: 0,who: 2,m: 2,c: 2], [x0: 7.76146881793,y0: -105.856441809,vx: 9.18417972401,vy: 0.673390521429,t0: 0,who: 2,m: 2,c: 2], [x0: 74.2641063642,y0: -81.4457136191,vx: 6.67759329359,vy: 6.08878572703,t0: 0,who: 2,m: 2,c: 2], [x0: -17.6320504064,y0: -26.5179468469,vx: 13.9999883599,vy: -9.30873351076,t0: 0,who: 2,m: 2,c: 2], [x0: 25.9955373462,y0: -118.105579863,vx: 8.4255966077,vy: 1.85450942736,t0: 0,who: 2,m: 2,c: 2], [x0: -3.97415724937,y0: 65.1752913773,vx: -11.7191217116,vy: -0.714590322835,t0: 0,who: 2,m: 2,c: 2], [x0: 62.9920197479,y0: -37.3848157096,vx: 5.65751549006,vy: 9.53270253468,t0: 0,who: 2,m: 2,c: 2], [x0: -55.6289736471,y0: 96.6135038187,vx: -7.78686375958,vy: -4.48358895759,t0: 0,who: 2,m: 2,c: 2], [x0: 57.5117086118,y0: -10.0733619124,vx: 2.14211583186,vy: 12.2299528803,t0: 0,who: 2,m: 2,c: 2], [x0: 19.2658345015,y0: 66.5458893527,vx: -10.9488305103,vy: 3.16981798046,t0: 0,who: 2,m: 2,c: 2], [x0: -40.7028932851,y0: 46.6514916174,vx: -9.08551168708,vy: -7.92700511426,t0: 0,who: 2,m: 2,c: 2], [x0: -29.9822834479,y0: 19.6178751052,vx: -8.67810174658,vy: -13.2628689377,t0: 0,who: 2,m: 2,c: 2], [x0: 42.9809721716,y0: -81.5045265374,vx: 8.74244371443,vy: 4.6102805079,t0: 0,who: 2,m: 2,c: 2], [x0: -8.39139335081,y0: 90.5206501443,vx: -9.90796371183,vy: -0.918482364841,t0: 0,who: 2,m: 2,c: 2], [x0: -54.7691558031,y0: 1.48044249503,vx: -0.346333858442,vy: -12.8126645355,t0: 0,who: 2,m: 2,c: 2], [x0: -7.70354535517,y0: -26.9648021343,vx: 17.2262713313,vy: -4.92135495154,t0: 0,who: 2,m: 2,c: 2], [x0: 19.0075281655,y0: -74.0714478767,vx: 10.5086803564,vy: 2.69664011683,t0: 0,who: 2,m: 2,c: 2], [x0: 93.8931063327,y0: -79.4086973834,vx: 5.52476644696,vy: 6.53250211325,t0: 0,who: 2,m: 2,c: 2], [x0: 42.4663280092,y0: -108.781445388,vx: 8.17835666565,vy: 3.1926839683,t0: 0,who: 2,m: 2,c: 2], [x0: -13.6569444921,y0: 42.4689454723,vx: -13.52249543,vy: -4.34849435105,t0: 0,who: 2,m: 2,c: 2], [x0: 20.9559260629,y0: -49.0767625301,vx: 11.9440870457,vy: 5.10016130068,t0: 0,who: 2,m: 2,c: 2], [x0: -107.449665978,y0: -49.6347358558,vx: 3.65699921678,vy: -7.91670062403,t0: 0,who: 2,m: 2,c: 2], [x0: 51.7272006346,y0: 83.7424286788,vx: -8.13576891034,vy: 5.02541611679,t0: 0,who: 2,m: 2,c: 2], [x0: 16.1438569591,y0: -34.2464912112,vx: 13.9468264453,vy: 6.5745588293,t0: 0,who: 2,m: 2,c: 2], [x0: -43.8193053814,y0: -58.9372731656,vx: 8.88419933891,vy: -6.6053182136,t0: 0,who: 2,m: 2,c: 2], [x0: 16.4663547679,y0: 15.3344141888,vx: -13.6306388802,vy: 14.6368118633,t0: 0,who: 2,m: 2,c: 2], [x0: -18.194664605,y0: -97.4008639603,vx: 9.368968478,vy: -1.75014093532,t0: 0,who: 2,m: 2,c: 2], [x0: 14.1903523105,y0: 24.7160370672,vx: -15.4119465911,vy: 8.8485444217,t0: 0,who: 2,m: 2,c: 2], [x0: -1.26943220782,y0: 28.6410078181,vx: -17.7015785308,vy: -0.784572737765,t0: 0,who: 2,m: 2,c: 2], [x0: -10.149275244,y0: 29.4888881842,vx: -16.06394859,vy: -5.52877527042,t0: 0,who: 2,m: 2,c: 2], [x0: 64.6102935123,y0: 101.555972056,vx: -7.29612303149,vy: 4.64182106698,t0: 0,who: 2,m: 2,c: 2], [x0: 64.5860197058,y0: -64.6176858015,vx: 7.02031831715,vy: 7.01687798856,t0: 0,who: 2,m: 2,c: 2], [x0: 61.4270711497,y0: -30.3736938024,vx: 5.07992830605,vy: 10.2735320742,t0: 0,who: 2,m: 2,c: 2], [x0: -63.7821786723,y0: -73.1429914271,vx: 7.25850011493,vy: -6.32955997821,t0: 0,who: 2,m: 2,c: 2], [x0: 107.816768059,y0: -40.4370133191,vx: 3.10474867165,vy: 8.27815755756,t0: 0,who: 2,m: 2,c: 2], [x0: 11.2138814822,y0: 20.2145724872,vx: -17.2552893837,vy: 9.57224152095,t0: 0,who: 2,m: 2,c: 2], [x0: -87.853108596,y0: 18.2330961017,vx: -2.0353262283,vy: -9.80687729423,t0: 0,who: 2,m: 2,c: 2], [x0: -111.433946739,y0: 77.0528656316,vx: -4.63579545497,vy: -6.70429294987,t0: 0,who: 2,m: 2,c: 2], [x0: -109.851523102,y0: -0.97353581415,vx: 0.0802162967011,vy: -9.05142085391,t0: 0,who: 2,m: 2,c: 2], [x0: 14.82947713,y0: 48.7861116864,vx: -12.7119394457,vy: 3.86403853004,t0: 0,who: 2,m: 2,c: 2], [x0: 52.6364866221,y0: -21.4677684706,vx: 4.75206870221,vy: 11.6515231201,t0: 0,who: 2,m: 2,c: 2], [x0: -17.636661778,y0: -61.1755686543,vx: 11.4248524255,vy: -3.29373739426,t0: 0,who: 2,m: 2,c: 2], [x0: -55.0008849936,y0: -108.455651604,vx: 7.67311184881,vy: -3.89124896765,t0: 0,who: 2,m: 2,c: 2], [x0: 14.667823136,y0: 66.2248803182,vx: -11.2469793275,vy: 2.49103815359,t0: 0,who: 2,m: 2,c: 2], [x0: -80.0650804922,y0: -56.2554817534,vx: 5.51382355992,vy: -7.84749705069,t0: 0,who: 2,m: 2,c: 2], [x0: 65.6879362382,y0: 62.2112600122,vx: -6.85874350525,vy: 7.24204438166,t0: 0,who: 2,m: 2,c: 2], [x0: -10.9706963687,y0: 138.090441514,vx: -8.03552403829,vy: -0.638388098564,t0: 0,who: 2,m: 2,c: 2], [x0: -93.9694782081,y0: 30.6087830327,vx: -2.95573301576,vy: -9.07415002148,t0: 0,who: 2,m: 2,c: 2]
Big: Way too long, see http://codepad.org/lacDfhB6

Some things need a bit of explanation: asteroids is number of small planets, not asteroids, mass is the central mass, not the mass of the asteroids. radius is random, using the random function (ex. start at 20, range of 120 is radius = random.random()*120+20.) To change the mass of the small-planets, modify the m at the end of the long code in the loop. I might upload another easier to use version of it when I'm not busy, posting this right now for viewtopic.php?f=7&t=181 .
$1 = 100¢ = (10¢)^2 = ($0.10)^2 = $0.01 = 1¢ [1]
Always check your units or you will have no money!
User avatar
wtg62
Posts: 174
Joined: Mon Jan 27, 2014 11:30 pm
Location: Texas, United States

Re: Accrete goes the asteroids

Post by wtg62 »

Ooooh... and they explode at 10x time rate too!
This message has been brought to you by wtg62, duh!
Post Reply