top of page

# rman_particles.py

# Creating a Ring Structure

import random
import gen_points_Ring
import math

def writeRing(path, num, innerR, outerR, particle_width, innerRGB, outerRGB):
    rib_file = open(path, 'w')
    data = gen_points_Ring.ring(num, innerR, outerR)
    rib_file.write('##bbox: -%f -%f -%f   %f %f %f\n' % (
            outerR,0,outerR, outerR, 0, outerR))
    rib_file.write('Points "P" [\n')
    for coord in data:
        rib_file.write('%f %f %f\n' % (coord[0],coord[1],coord[2] ) )
    rib_file.write('] "constantwidth" [%f]\n' % particle_width)
    # Now for the color information__________________________
    rib_file.write('"varying color tint" [\n')
    diff = outerR - innerR
    for x,y,z in data:
        radial_ratio = (math.sqrt(x * x + z * z) - innerR)/diff
        r,g,b = mix( innerRGB, outerRGB, radial_ratio)
        rib_file.write('%f %f %f\n' % (r,g,b) )
    rib_file.write(']\n')
    #_________________________________________________________    
    rib_file.close()
#----------------------------------------------------------------------------
def mix(c1, c2, blend):
    red = c1[0] * (1- blend) + c2[0] * (blend)
    green = c1[1] * (1- blend) + c2[1] * (blend)
    blue = c1[2] * (1- blend) + c2[2] * (blend)
    return (red,green,blue)
#----------------------------------------------------------------------------

}

------------------------------------------------------------------------------

#Saturn


writeRing('path/data_SRing1.rib', 200000, 3.75, 3.8, 0.01, [0.4,0.329,0.329], [0.4,0.337,0.329])
writeRing('path/data_SRing2.rib', 200000, 3.5, 3.725, 0.01, [0.4,0.352,0.313], [0.4,0.329,0.329])
writeRing('path/data_SRing3.rib', 200000, 3.45, 3.485, 0.01, [0.4,0.352,0.313], [0.4,0.352,0.313])
writeRing('path/data_SRing4.rib', 200000, 3.4, 3.45, 0.01, [0.4,0.321,0.258], [0.4,0.352,0.313])
writeRing('path/data_SRing5.rib', 200000, 3.36, 3.4, 0.005, [0.2,0.160,0.129], [0.2,0.160,0.129])
writeRing('path/data_SRing6.rib', 200000, 3.0, 3.325, 0.01, [0.4,0.321,0.258], [0.607,0.501,0.415])
writeRing('path/data_SRing7.rib', 200000, 2.75, 2.985, 0.01, [0.168,0.133,0.101], [0.4,0.321,0.258])
writeRing('path/data_SRing8.rib', 800000, 2.5, 3, 0.01, [0.109,0.078,0.054], [0.109,0.078,0.054])

bottom of page