Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- from datetime import datetime
- # AsteroidsRingMaker
- # by JackDole
- # 2016.03.15 16:36:56
- # converted to Python and enhanced by FaceDeer
- #daysYear = 365.24218985
- #AU = 149597870.691
- #eMass = 5.9736e24
- #uncomment this line if you want repeatable results
- #random.seed(100)
- # Amount of asteroids
- NumberOfAster=200
- # Name of the asteroids - a serial number is appended
- AsterName='Vulkanoid'
- RingCenter='Sol'
- # Orbital radii in AU
- InnerRadius=0.15
- OuterRadius=0.18
- # Radius of asteroids in KM
- MaxRadiusOfAster=3
- MinRadiusOfAster=0.1
- #orbital eccentricity
- MaxEccentricity=0.001
- MinEccentricity=0
- # Orbital inclination +- in degrees
- MaxInclination=10
- #Probability that the asteroid won't be given a rotation rate, leaving it tide-locked
- ChanceOfTideLock = 0.1
- #rotation periods in hours. See https://www.boulder.swri.edu/~bottke/rubble/node3.html
- MaxRotationPeriod = 12
- MinRotationPeriod = 0.1
- RefPlane='Ecliptic'
- epoch=2457395.5
- FileName= '{0}_{1}.sc'.format(AsterName, NumberOfAster)
- template ="""
- Asteroid "{AsterName} {count}"
- {{
- \tParentBody\t"{RingCenter}"
- \tClass\t\t"Asteroid"
- \tRadius\t\t{radius}
- {rotation}
- \tOrbit
- \t{{
- \t\tEpoch\t\t\t{epoch}
- \t\tSemiMajorAxis\t{semi}
- \t\tEccentricity\t{eccen}
- \t\tInclination\t\t{incl}
- \t\tAscendingNode\t{ascen}
- \t\tArgOfPericen\t{argof}
- \t\tMeanAnomaly\t\t0.0
- \t\tRefPlane\t\t"{RefPlane}"
- \t}}
- }}
- """
- #three different random number generators that give a floating point number between
- #the two parameters but with different distributions
- def uniform(a, b):
- return random.uniform(a, b)
- def triangular(a, b):
- return random.triangular(a, b, (a+b)/2.0)
- # A normal distribution placing a and b at three standard deviations out from the mean
- # clamping the result so that there are no outliers beyond the desired range
- def gaussian(a, b):
- result = random.gauss((a+b)/2.0, (b-a)/6.0)
- return max(min(result, b), a)
- randomGenerator = gaussian
- parameters = {'AsterName' : AsterName, 'RingCenter' : RingCenter, 'RefPlane' : RefPlane, 'epoch' : epoch}
- with open(FileName, 'w') as outputfile:
- outputfile.write('// Asteroids made with AsteroidsRingMaker\n// {0}\n\n'.format(datetime.today()))
- for count in range(NumberOfAster):
- parameters['count'] = count
- parameters['semi'] = randomGenerator(InnerRadius, OuterRadius)
- parameters['radius'] = randomGenerator(MinRadiusOfAster, MaxRadiusOfAster)
- parameters['incl'] = randomGenerator(-MaxInclination, MaxInclination)
- parameters['eccen'] = randomGenerator(MinEccentricity, MaxEccentricity)
- parameters['argof'] = random.uniform(0,360)
- parameters['ascen'] = random.uniform(0,360)
- if random.random() > ChanceOfTideLock:
- rotation = randomGenerator(MinRotationPeriod,MaxRotationPeriod)
- obliquity = random.uniform(0,360)
- parameters['rotation'] = '\tRotationPeriod\t{0}\n\tObliquity\t\t{1}\n'.format(rotation, obliquity)
- else:
- parameters['rotation'] = ''
- outputfile.write(template.format(**parameters))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement