#!/usr/bin/env python3 from math import * import random # size of space L=30 # number of rods N=75 # aspect ratio a=10 # spread in theta angle spread=pi/30 # check whether two rods overlap def check_overlap(rod1,rod2): # relative placement relative_pos=unrotate(subtract(rod2[0],rod1[0]), rod1[1]) if(abs(relative_pos[0])<2 and abs(relative_pos[1])<2 and abs(relative_pos[2])<2): return(True) # relative angle relative_ang=cart_to_spherical(unrotate(spherical_to_cart(rod2[1]), rod1[1])) # exclusion volume # rotate other rod relative_pos=unrotate(relative_pos, [0,relative_ang[1]]) #if(abs(relative_pos[1])<2 and abs(relative_pos[0])-21 and abs(c)<1.0001): if(c>0): return([w[0],0]) else: return([w[0],pi]) if(s>=0): return([w[0],acos(c)]) return([w[0],2*pi-acos(c)]) # configuration config=[] # add rods while len(config)