예제 #1
0
파일: hilbert.py 프로젝트: bh0085/compbio
  def __init__(self, lvl, angle = 90, 
               start = array([0.0,0.0]),
               finish = array([1.0,0.0])):


    
    step = 1.0 / pow(2,lvl)
    t = lilturtle.lilturtle(angle, step)
    t.hilbert(lvl)
    self.curve = t.curve()
    c0 = self.curve[0,:]
    self.curve = self.curve - c0
    last = self.curve[-1,:]
    x,y = last

    delta_in = finish - start
    theta_in = arctan(delta_in[1]/delta_in[0])
    if delta_in[0] < 0: theta_in = theta_in + pi
    theta = arctan(y/x)
    if x < 0: theta = pi + theta
    dtheta = theta - theta_in

    norm_ratio =sqrt( (np.sum(square([x,y]))) /(np.sum(np.square(delta_in))))

    mat = [[cos(dtheta), sin(dtheta)],
           [-sin(dtheta),cos(dtheta)]] *1/norm_ratio
    
    self.step = step / norm_ratio
    curve2 = array(mat[newaxis,:,0] * self.curve[:,newaxis,0] + 
                    mat[newaxis,:,1] * self.curve[:,newaxis,1]) + \
                    start
                      
    self.curve = curve2
    self.units =t.getUnits()
예제 #2
0
파일: plots.py 프로젝트: bh0085/everySNAKE
def spacefill(ax,rs, cs):
  import compbio.utils.lilturtle as lt
  
  t = lt.lilturtle(90)
  l = len(rs)
  levs = t.inverseN(l)
  t.hilbert(levs)
  c = t.curve()

  xs = c[:l,0]
  ys = c[:l,1]

  ax.plot(xs,ys, zorder = -1, alpha = .2, color = 'black')
  ax.scatter(xs,ys,rs,color = cs)