def get_tikzpicture_body_beta(fs): """ This alternative visualization literally warps the x axis. The other one makes a smoother picture by computing a different function for y that is equivalent to this warping. """ ncurves = fs.ncurves morph = fs.morph # define the number of segments nsegs = 128 npoints = nsegs + 1 t_initial = -1.0 t_final = 1.0 incr = (t_final - t_initial) / float(nsegs) # define the sequence of t values t_seq = [t_initial + t*incr for t in range(npoints)] t_seq_inv_warped = [ inv_warp(t)*morph + t*(1-morph) for t in t_seq] # define the sequences of y values y_seqs = [] for i in range(ncurves): mypoly = sympy.chebyshevt_poly(i+1, sympy.abc.x, polys=True) y_seqs.append([mypoly.eval(t) for t in t_seq]) width = 8 height = 4 text = interlace.tikz_superposition( t_seq_inv_warped, y_seqs, width, height) return text
def __init__(self): # predefine the shape self.initial_t = -1.0 self.final_t = 1.0 self.polys = [sympy.chebyshevt_poly( i+1, sympy.abc.t, polys=True) for i in range(3)] self.shape = interlace.CubicPolyShape( self.polys, self.initial_t, self.final_t)
def __init__(self): # predefine the shape self.initial_t = -1.0 self.final_t = 1.0 self.polys = [ sympy.chebyshevt_poly(i + 1, sympy.abc.t, polys=True) for i in range(3) ] self.shape = interlace.CubicPolyShape(self.polys, self.initial_t, self.final_t)
def get_tikzpicture_body_gamma(fs): """ This was the latest pre-bezier version. """ ncurves = fs.ncurves morph = fs.morph # define the number of segments nsegs = 128 npoints = nsegs + 1 t_initial = -1.0 t_final = 1.0 incr = (t_final - t_initial) / float(nsegs) # define the sequence of t values t_seq = [t_initial + t*incr for t in range(npoints)] # define the sequences of y values y_seqs = [] for i in range(ncurves): mypoly = sympy.chebyshevt_poly(i+1, sympy.abc.x, polys=True) y_seq = [mypoly.eval(warp(t)*morph + t*(1-morph)) for t in t_seq] y_seqs.append(y_seq) width = 8 height = 4 return interlace.tikz_superposition(t_seq, y_seqs, width, height)
def get_tikzpicture_body(ncurves, nsegs, morph): """ Try to use sympy for computation and bezier for drawing. """ # define the sympy expression for the warp sympy_t = sympy.abc.t sympy_t_warped = sympy.sin((sympy.pi / 2) * sympy_t) sympy_t_morphed = morph*sympy_t_warped + (1-morph)*sympy_t # define the shapes shapes = [] x_axis = interlace.PiecewiseLinearPathShape([(-1, 0), (1, 0)]) shapes.append(x_axis) for i in range(ncurves): x_expr = sympy_t y_expr = sympy.chebyshevt_poly(i+1, sympy_t_morphed) #cheby_expr = sympy.chebyshevt_poly(i+1, sympy_t) #y_expr = cheby_expr.subs(sympy_t, sympy_t_morphed) shape = interlace.DifferentiableShape( (x_expr, y_expr), -1.0, 1.0, nsegs) shapes.append(shape) width = 6 height = 6 return interlace.tikz_shape_superposition(shapes, width, height)