示例#1
0
def get_world_segments(root_a, root_b, root_c, initial_t, final_t,
                       intersection_radius):
    """
    The world consists of
    three axis lines,
    six circles marking the intersections,
    and a single parametric curve.
    @return: a collection of (p0, p1, style) triples
    """
    seg_length_min = 0.1
    segments = []
    # add the axis line segments
    d = 5
    f_x = pcurve.LineSegment(np.array([-d, 0, 0]), np.array([d, 0, 0]))
    f_y = pcurve.LineSegment(np.array([0, -d, 0]), np.array([0, d, 0]))
    f_z = pcurve.LineSegment(np.array([0, 0, -d]), np.array([0, 0, d]))
    x_axis_segs = pcurve.get_piecewise_curve(f_x, 0, 1, 10, seg_length_min)
    y_axis_segs = pcurve.get_piecewise_curve(f_y, 0, 1, 10, seg_length_min)
    z_axis_segs = pcurve.get_piecewise_curve(f_z, 0, 1, 10, seg_length_min)
    segments.extend((p0, p1, STYLE_X) for p0, p1 in x_axis_segs)
    segments.extend((p0, p1, STYLE_Y) for p0, p1 in y_axis_segs)
    segments.extend((p0, p1, STYLE_Z) for p0, p1 in z_axis_segs)
    # add the parametric curve
    roots = (root_a, root_b, root_c)
    polys = interlace.roots_to_differential_polys(roots)
    f_poly = interlace.Multiplex((sympyutils.WrappedUniPoly(p) for p in polys))
    poly_segs = pcurve.get_piecewise_curve(f_poly, initial_t, final_t, 10,
                                           seg_length_min)
    segments.extend((p0, p1, STYLE_CURVE) for p0, p1 in poly_segs)
    # add the intersection circles
    x_roots_symbolic = sympy.roots(polys[0])
    y_roots_symbolic = sympy.roots(polys[1])
    z_roots_symbolic = sympy.roots(polys[2])
    x_roots = [float(r) for r in x_roots_symbolic]
    y_roots = [float(r) for r in y_roots_symbolic]
    z_roots = [float(r) for r in z_roots_symbolic]
    for r in x_roots:
        f = pcurve.OrthoCircle(f_poly(r), intersection_radius, 0)
        segs = pcurve.get_piecewise_curve(f, 0, 1, 10, seg_length_min)
        segments.extend((p0, p1, STYLE_X) for p0, p1 in segs)
    for r in y_roots:
        f = pcurve.OrthoCircle(f_poly(r), intersection_radius, 1)
        segs = pcurve.get_piecewise_curve(f, 0, 1, 10, seg_length_min)
        segments.extend((p0, p1, STYLE_Y) for p0, p1 in segs)
    for r in z_roots:
        f = pcurve.OrthoCircle(f_poly(r), intersection_radius, 2)
        segs = pcurve.get_piecewise_curve(f, 0, 1, 10, seg_length_min)
        segments.extend((p0, p1, STYLE_Z) for p0, p1 in segs)
    # return the segments
    return segments
示例#2
0
def get_world_segments(root_a, root_b, root_c, initial_t, final_t, intersection_radius):
    """
    The world consists of
    three axis lines,
    six circles marking the intersections,
    and a single parametric curve.
    @return: a collection of (p0, p1, style) triples
    """
    seg_length_min = 0.1
    segments = []
    # add the axis line segments
    d = 5
    f_x = pcurve.LineSegment(np.array([-d, 0, 0]), np.array([d, 0, 0]))
    f_y = pcurve.LineSegment(np.array([0, -d, 0]), np.array([0, d, 0]))
    f_z = pcurve.LineSegment(np.array([0, 0, -d]), np.array([0, 0, d]))
    x_axis_segs = pcurve.get_piecewise_curve(f_x, 0, 1, 10, seg_length_min)
    y_axis_segs = pcurve.get_piecewise_curve(f_y, 0, 1, 10, seg_length_min)
    z_axis_segs = pcurve.get_piecewise_curve(f_z, 0, 1, 10, seg_length_min)
    segments.extend((p0, p1, STYLE_X) for p0, p1 in x_axis_segs)
    segments.extend((p0, p1, STYLE_Y) for p0, p1 in y_axis_segs)
    segments.extend((p0, p1, STYLE_Z) for p0, p1 in z_axis_segs)
    # add the parametric curve
    roots = (root_a, root_b, root_c)
    polys = interlace.roots_to_differential_polys(roots)
    f_poly = interlace.Multiplex((sympyutils.WrappedUniPoly(p) for p in polys))
    poly_segs = pcurve.get_piecewise_curve(f_poly, initial_t, final_t, 10, seg_length_min)
    segments.extend((p0, p1, STYLE_CURVE) for p0, p1 in poly_segs)
    # add the intersection circles
    x_roots_symbolic = sympy.roots(polys[0])
    y_roots_symbolic = sympy.roots(polys[1])
    z_roots_symbolic = sympy.roots(polys[2])
    x_roots = [float(r) for r in x_roots_symbolic]
    y_roots = [float(r) for r in y_roots_symbolic]
    z_roots = [float(r) for r in z_roots_symbolic]
    for r in x_roots:
        f = pcurve.OrthoCircle(f_poly(r), intersection_radius, 0)
        segs = pcurve.get_piecewise_curve(f, 0, 1, 10, seg_length_min)
        segments.extend((p0, p1, STYLE_X) for p0, p1 in segs)
    for r in y_roots:
        f = pcurve.OrthoCircle(f_poly(r), intersection_radius, 1)
        segs = pcurve.get_piecewise_curve(f, 0, 1, 10, seg_length_min)
        segments.extend((p0, p1, STYLE_Y) for p0, p1 in segs)
    for r in z_roots:
        f = pcurve.OrthoCircle(f_poly(r), intersection_radius, 2)
        segs = pcurve.get_piecewise_curve(f, 0, 1, 10, seg_length_min)
        segments.extend((p0, p1, STYLE_Z) for p0, p1 in segs)
    # return the segments
    return segments
示例#3
0
def get_tikz_lines(fs):
    """
    @param fs: user input
    @return: a sequence of tikz lines
    """
    roots = (fs.root_a, fs.root_b, fs.root_c)
    nsegs = 128
    npoints = nsegs + 1
    incr = (fs.final_t - fs.initial_t) / nsegs
    polys = interlace.roots_to_differential_polys(roots)
    t_values = [fs.initial_t + incr*i for i in range(npoints)]
    # get the tikz lines
    lines = []
    lines.extend(get_function_tikz_lines(
        (lambda t: 0), (t_values[0], t_values[-1]), 'black'))
    colors = ('w-blue', 'w-red', 'w-olive')
    for p, color in zip(polys, colors):
        lines.extend(get_function_tikz_lines(
            p.eval, t_values, color))
    return lines
示例#4
0
def get_tikz_lines(fs):
    """
    @param fs: user input
    @return: a sequence of tikz lines
    """
    roots = (fs.root_a, fs.root_b, fs.root_c)
    nsegs = 128
    npoints = nsegs + 1
    incr = (fs.final_t - fs.initial_t) / nsegs
    polys = interlace.roots_to_differential_polys(roots)
    t_values = [fs.initial_t + incr * i for i in range(npoints)]
    # get the tikz lines
    lines = []
    lines.extend(
        get_function_tikz_lines((lambda t: 0), (t_values[0], t_values[-1]),
                                'black'))
    colors = ('w-blue', 'w-red', 'w-olive')
    for p, color in zip(polys, colors):
        lines.extend(get_function_tikz_lines(p.eval, t_values, color))
    return lines
示例#5
0
def get_tikz_lines(fs):
    """
    @param fs: user input
    @return: a sequence of tikz lines
    """
    # construct a 'matrix' of three vertically stacked panes
    colors = ("black", "w-blue", "w-red", "w-olive")
    p0 = sympy.Poly(1, sympy.abc.x)
    roots = (fs.root_a, fs.root_b, fs.root_c)
    polys = [p0] + interlace.roots_to_differential_polys(roots)
    # get the tikz lines
    lines = []
    lines.append("\\matrix {")
    lines.extend(get_pane_tikz_lines(polys[0:2], colors[0:2], fs.initial_t, fs.final_t))
    lines.append("\\\\")
    lines.extend(get_pane_tikz_lines(polys[1:3], colors[1:3], fs.initial_t, fs.final_t))
    lines.append("\\\\")
    lines.extend(get_pane_tikz_lines(polys[2:4], colors[2:4], fs.initial_t, fs.final_t))
    lines.append("\\\\")
    lines.append("};")
    return lines
示例#6
0
def get_tikz_lines(fs):
    """
    @param fs: user input
    @return: a sequence of tikz lines
    """
    # construct a 'matrix' of three vertically stacked panes
    colors = ('black', 'w-blue', 'w-red', 'w-olive')
    p0 = sympy.Poly(1, sympy.abc.x)
    roots = (fs.root_a, fs.root_b, fs.root_c)
    polys = [p0] + interlace.roots_to_differential_polys(roots)
    # get the tikz lines
    lines = []
    lines.append('\\matrix {')
    lines.extend(get_pane_tikz_lines(
        polys[0:2], colors[0:2], fs.initial_t, fs.final_t))
    lines.append('\\\\')
    lines.extend(get_pane_tikz_lines(
        polys[1:3], colors[1:3], fs.initial_t, fs.final_t))
    lines.append('\\\\')
    lines.extend(get_pane_tikz_lines(
        polys[2:4], colors[2:4], fs.initial_t, fs.final_t))
    lines.append('\\\\')
    lines.append('};')
    return lines