import rhinoscriptsyntax as rs
import sys, random  ###                                              
sys.path.append("P:/")     ### add path where "DM_lib.py" can be found !!!                                              
#sys.path.append("P:/DM2/")     ### add path where "DM_lib.py" can be found !!!                                              
#sys.path.append("P:/dm2/")     ### add path where "DM_lib.py" can be found !!!                                              
import DM_lib as dm        ### reload(dm)    
############################## 


rs.UnitSystem(3)
dm.PointRadius(displayModeX=1, rad=2, styl=3, verbose=1)

if 1:
    rs.EnableRedraw(0)
    #delete absolutely all
    dm.eA()
    #print "pntRandVec",dm.pntRandVec(-1,1)
    
    anz = 5500
    deltaAngle = 360/anz
    rad = random.uniform(5.0, 10)
    vec = [rad, 0,0]
    #rs.AddPoint(vec)
    #vecX = rs.VectorRotate(vec,29.0,[0,1,1])
    #rs.AddPoint(vecX)
    
    coords = []
    for i in range(anz):
        vecX = rs.VectorRotate(vec, random.uniform(0,270), [0,0,1])
        vecX = rs.VectorRotate(vecX, random.uniform(0,270), [0,1,0])
        coords.append( vecX )
rs.AddPoints(coords)

pln0 =rs.PlaneFromNormal([0,0,0], [0,1,1], xaxis=[0,1,0])

#circ0 = rs.AddCircle( pln0, rad)
circ0 = rs.AddArc(pln0, rad, 90)
rs.RotateObject(circ0, [0,0,0], 90,[0,0,1])
rs.ObjectPrintColor(circ0, [0,200,0])
rs.ObjectPrintWidth(circ0, 0.2 )
        #print deltaAngle*i
dm.printDisplay(state=1, scale=10, thickness=1, color='Display')
lin0 = rs.AddLine( rs.CurveStartPoint(circ0), rs.CurveEndPoint(circ0))
rs.ObjectPrintColor(lin0, [0,200,220])
rs.ObjectPrintWidth(lin0, 0.2 )
coordsC = rs.DivideCurve(circ0, 1001, 0)
coordsL = rs.DivideCurve(lin0, 1001, 0)

fuellCoords = []
for i in range(1001):
    
    pC = random.choice(coordsC)
    pL = random.choice(coordsL)
    #rs.AddCurve( [pC, pL] )
    pX = dm.pntInbetween(pC, pL, random.uniform(0,1))
    fuellCoords.append( pX )
rs.ObjectColor(rs.AddPoints(fuellCoords), [200,160,0] )
    
    