################################################################################################### 
# Demonstrate use of Vector Scan: one or multiple positioners set with a list or generator.
################################################################################################### 



#1D vector scan, positions in a list
vector = [ 1, 3, 5, 10, 25, 40, 45, 47, 49, 20, 2]
#r1 = vscan(inp,(out,sin),vector,False, 0.5, title = "1D Vector")


#1D vector scan, positions given by a generator
def gen():    
    num = 0.0
    while num < 10:
        yield num
        num += 1
#v2 = vscan(ao1,(ai1,ai2),gen(),False, 0.5, title = "1D Generator")


vector = [  [1,1] , [1,2] , [1,3] , [1,4]   ,
                     [1.5,2.5]              , 
            [2,1] , [2,2] , [2,3] , [2,4]   ,
                     [2.5,2.5]              ,
            [3,1] , [3,2] , [3,3] , [3,4]   , [2.1, 2.1]  ]

r3 = vscan((m1,m2),(wf1, ai1,ai2),vector,False, 0.1, title = "2D Vector")            


#2D vector scan, positions given by a generator
def gen():    
    a= 0
    while abs(a) < len(vector):
        
            yield vector[a]
            a=a+1


#r2 = vscan((m1,m2),(ai1,ai2),gen(),False, 0.1, title = "2D Generator", range = [0.0,5.0, 0.0, 5.0])


def spiral_gen(radius, step, resolution=.1, angle=0.0, origin=[0.0, 0.0]):
    d = 0.0
    while d * math.hypot(math.cos(angle), math.sin(angle)) < radius:
        cord=[]
        cord.append(origin[0] + d * math.cos(angle))
        cord.append(origin[1] + d * math.sin(angle))
        yield(cord)
        d+=step
        angle+=resolution

spiral = spiral_gen(10, 0.1)
#for  i in spiral_gen(10, 1, 0.1, 0.0, 0.0):
#    print i
    
#r2 = vscan((m1,m2),(wf1, ai1,ai2),spiral,False, 0.1, title = "2D Generator", range = [-10.0,10.0, -10.0, 10.0])        
    