#! python 2
############################
### diag @ IAM @ DM2_w25 ###
### hu_02 setUp_ver00    ### see examples @ DM2_w23 hu_02 !
############################


##############################
import rhinoscriptsyntax as rs
import random, time, sys   ###
sys.path.append("P:/")     ###                  ### diag's path to DM_lib.py  .. please keep it !                                               
sys.path.append("P:/TUGonlineUsernam/dm2/")     ### *your* path to DM_lib.py                                            
sys.path.append("P:/WWW/TUGonlineUsernam/dm2/") ### *your* path to DM_lib.py                                            
sys.path.append("/Users/macpro/Desktop/DM2")    ### *your* path to DM_lib.py      
import DM_lib as dm        ###                  ### "dm" is alias for DM_lib / for adressing definitions etc in "DM_lib.py"
############################## reload(dm)

rs.ShowGrid(show=0)
rs.ShowGridAxes(show=0)
rs.ViewDisplayMode(mode="Wireframe")
rs.EnableRedraw(0)

dm.PointRadius(displayModeX=0, rad=3, styl=3)                   ### displayModeX=0="Wireframe" / rad=size of points / styl=pointStyle (try 0..5) / default 3, 3
dm.printDisplay(state=1, scale=1, thickness=1, color="Display") ### state=0/1 = off/on / for showing printWidth etc

rs.DeleteObjects(rs.AllObjects())

### BASIC SETUP / mandatory input:
### return_value of definition "dm.setUp_hu_02(..)" is 1 array containing 2 coord_arrays: [ [coordsCir], [coordsSqu] ] (circle & square)
### anzahl == number of coords: range from 8 to 1001 / 4*250 / default = 4*32 
### rotateSqu .. rotation of square_coords: may be set to/try (0, 0)..(-90,90) .. etc / default = (-90, 90)
allCoords = dm.setUp_hu_02( anzahl=4*32,  rotateSqu=random.uniform(-90,90) )
coordsCir=allCoords[0]
coordsSqu=allCoords[1]

##### check setup - just visualization of coords
##### don't execute  @ final version of homework

if 0: ### 0 for *your* final version !
    if 1:
        rs.AddPoints( coordsCir )
        rs.AddPoints( coordsSqu )
    if 0:
        rs.ObjectColor(dm.textDots(coordsCir), [111,0,11])
        rs.ObjectColor(dm.textDots(coordsSqu), [11,0,111])
    if 0:
        rs.AddCurve( coordsCir, 1)
        rs.AddCurve( coordsSqu, 1)
        for i in range( len(coordsSqu) ):
            p0  = coordsCir[i]
            p1  = coordsSqu[i]
            lin = rs.AddLine(p0, p1)
            rs.ObjectColor(lin, [222*(i!=0), 22*(i!=0), 222])
            rs.ObjectPrintWidth( lin, 1.0*(i==0) )
##### end check setup

#######################################
################ HERE YOU GO AS YOU GO:

amount_segments = 10 # Anzahl der Unterteilungen

for i in range(len(coordsCir)): # loop, der von 0 bis Anzahl der Punkte - 1 geht
    rs.AddLine(coordsCir[i], coordsSqu[i]) # zeichnet Linie zwischen Punkt von dem Kreis und Punkt von dem Viereck

    start_point = coordsCir[i] # Definition des starpunktes für meine rechnung
    step = (coordsSqu[i] - coordsCir[i]) / amount_segments # Definition abstandes der Koordinaten

    for i2 in range(amount_segments + 1): # loop, der von 1 bis 10 geht
        rs.AddPoint(start_point) # zeichnet punkt
        start_point = start_point + step # definiert meinen startpunkt immer neu um die segmente abzuarbeiten

#################
#rs.ZoomExtents()
rs.Command("-zoom extents enter -zoom Factor 0.9 enter", 0) # change zoom for better framing




