示例#1
0
def box_mitered(a, b):
    """ A box with the given bounds, which will stay creased if offset
    """
    args = [list([Shape.wrap(i) for i in a]), list([Shape.wrap(i) for i in b])]
    return Shape(
        stdlib.box_mitered(tvec3(*[a.ptr for a in args[0]]),
                           tvec3(*[a.ptr for a in args[1]])))
示例#2
0
def box_exact(a, b):
    """ A box with the given bounds with a Euclidean distance metric
    """
    args = [list([Shape.wrap(i) for i in a]), list([Shape.wrap(i) for i in b])]
    return Shape(
        stdlib.box_exact(tvec3(*[a.ptr for a in args[0]]),
                         tvec3(*[a.ptr for a in args[1]])))
示例#3
0
def box_exact_centered(size, center=(0, 0, 0)):
    """ A box with the given size, centered around the given point,
        with a Euclidean distance metric
    """
    args = [list([Shape.wrap(i) for i in size]), list([Shape.wrap(i) for i in center])]
    return Shape(stdlib.box_exact_centered(
        tvec3(*[a.ptr for a in args[0]]),
        tvec3(*[a.ptr for a in args[1]])))
示例#4
0
def scale_xyz(t, s, center=(0, 0, 0)):
    """ Scales a shape on all three axes, about 0 or an optional offset
    """
    args = [Shape.wrap(t), list([Shape.wrap(i) for i in s]), list([Shape.wrap(i) for i in center])]
    return Shape(stdlib.scale_xyz(
        args[0].ptr,
        tvec3(*[a.ptr for a in args[1]]),
        tvec3(*[a.ptr for a in args[2]])))
示例#5
0
def half_space(norm, point=(0, 0, 0)):
    """ A plane which divides the world into inside and outside, defined by its
        normal and a single point on the plane
    """
    args = [list([Shape.wrap(i) for i in norm]), list([Shape.wrap(i) for i in point])]
    return Shape(stdlib.half_space(
        tvec3(*[a.ptr for a in args[0]]),
        tvec3(*[a.ptr for a in args[1]])))
示例#6
0
def rounded_box(a, b, r):
    """ Rounded box with the given bounds and radius (as a 0-1 fraction)
    """
    args = [list([Shape.wrap(i) for i in a]), list([Shape.wrap(i) for i in b]), Shape.wrap(r)]
    return Shape(stdlib.rounded_box(
        tvec3(*[a.ptr for a in args[0]]),
        tvec3(*[a.ptr for a in args[1]]),
        args[2].ptr))
示例#7
0
def box_mitered_centered(size, center=(0, 0, 0)):
    """ A box with the given size and (optional) center, with edges that
        will stay sharp if offset.
    """
    args = [list([Shape.wrap(i) for i in size]), list([Shape.wrap(i) for i in center])]
    return Shape(stdlib.box_mitered_centered(
        tvec3(*[a.ptr for a in args[0]]),
        tvec3(*[a.ptr for a in args[1]])))
示例#8
0
def loft_between(a, b, lower, upper):
    """ Produces a blended loft between a (at lower.z) and b (at upper.z),
        with XY coordinates remapped to slide between lower.xy and upper.xy.
        a and b should be 2D shapes (i.e. invariant along the z axis)
    """
    args = [Shape.wrap(a), Shape.wrap(b), list([Shape.wrap(i) for i in lower]), list([Shape.wrap(i) for i in upper])]
    return Shape(stdlib.loft_between(
        args[0].ptr,
        args[1].ptr,
        tvec3(*[a.ptr for a in args[2]]),
        tvec3(*[a.ptr for a in args[3]])))
示例#9
0
def gyroid(period, thickness):
    """ A volume-filling gyroid with the given periods and thickness
    """
    args = [list([Shape.wrap(i) for i in period]), Shape.wrap(thickness)]
    return Shape(stdlib.gyroid(
        tvec3(*[a.ptr for a in args[0]]),
        args[1].ptr))
示例#10
0
def move(t, offset):
    """ Moves the given shape in 2D or 3D space
    """
    args = [Shape.wrap(t), list([Shape.wrap(i) for i in offset])]
    return Shape(stdlib.move(
        args[0].ptr,
        tvec3(*[a.ptr for a in args[1]])))
示例#11
0
def sphere(radius, center=(0, 0, 0)):
    """ A sphere with the given radius and (optional) center
    """
    args = [Shape.wrap(radius), list([Shape.wrap(i) for i in center])]
    return Shape(stdlib.sphere(
        args[0].ptr,
        tvec3(*[a.ptr for a in args[1]])))
示例#12
0
def cylinder_z(r, h, base=(0, 0, 0)):
    """ A cylinder with the given radius and height, extruded from the
        (optional) base position.
    """
    args = [Shape.wrap(r), Shape.wrap(h), list([Shape.wrap(i) for i in base])]
    return Shape(
        stdlib.cylinder_z(args[0].ptr, args[1].ptr,
                          tvec3(*[a.ptr for a in args[2]])))
示例#13
0
def torus_z(ro, ri, center=(0, 0, 0)):
    """ A torus with the given outer radius, inner radius, and (optional) center
    """
    args = [Shape.wrap(ro), Shape.wrap(ri), list([Shape.wrap(i) for i in center])]
    return Shape(stdlib.torus_z(
        args[0].ptr,
        args[1].ptr,
        tvec3(*[a.ptr for a in args[2]])))
示例#14
0
def cone_z(radius, height, base=(0, 0, 0)):
    """ A cone defined by its radius, height, and (optional) base location
    """
    args = [Shape.wrap(radius), Shape.wrap(height), list([Shape.wrap(i) for i in base])]
    return Shape(stdlib.cone_z(
        args[0].ptr,
        args[1].ptr,
        tvec3(*[a.ptr for a in args[2]])))
示例#15
0
def twirl_z(shape, amount, radius, center=(0, 0, 0)):
    """ Twirls the shape in the z axis about the (optional) center point
    """
    args = [Shape.wrap(shape), Shape.wrap(amount), Shape.wrap(radius), list([Shape.wrap(i) for i in center])]
    return Shape(stdlib.twirl_z(
        args[0].ptr,
        args[1].ptr,
        args[2].ptr,
        tvec3(*[a.ptr for a in args[3]])))
示例#16
0
def rotate_z(t, angle, center=(0, 0, 0)):
    """ Rotate the given shape by an angle in radians
        The center of rotation is [0 0 0] or specified by the optional argument
    """
    args = [Shape.wrap(t), Shape.wrap(angle), list([Shape.wrap(i) for i in center])]
    return Shape(stdlib.rotate_z(
        args[0].ptr,
        args[1].ptr,
        tvec3(*[a.ptr for a in args[2]])))
示例#17
0
def attract_z(shape, locus, radius, exaggerate=1):
    """ Attracts the shape away from a XY plane based upon a radius r,
        with optional exaggeration
    """
    args = [Shape.wrap(shape), list([Shape.wrap(i) for i in locus]), Shape.wrap(radius), Shape.wrap(exaggerate)]
    return Shape(stdlib.attract_z(
        args[0].ptr,
        tvec3(*[a.ptr for a in args[1]]),
        args[2].ptr,
        args[3].ptr))
示例#18
0
def attract_xz(shape, locus, radius, exaggerate=1):
    """ Attracts the shape away from line parallel to the Y axis,
        with a particular radius and optional exaggeration
    """
    args = [Shape.wrap(shape), list([Shape.wrap(i) for i in locus]), Shape.wrap(radius), Shape.wrap(exaggerate)]
    return Shape(stdlib.attract_xz(
        args[0].ptr,
        tvec3(*[a.ptr for a in args[1]]),
        args[2].ptr,
        args[3].ptr))
示例#19
0
def array_xyz(shape, nx, ny, nz, delta):
    """ Iterates a part in a 3D array
    """
    args = [
        Shape.wrap(shape), nx, ny, nz,
        list([Shape.wrap(i) for i in delta])
    ]
    return Shape(
        stdlib.array_xyz(args[0].ptr, args[1], args[2], args[3],
                         tvec3(*[a.ptr for a in args[4]])))
示例#20
0
def repel(shape, locus, radius, exaggerate=1):
    """ Repels the shape away from a point based upon a radius r,
        with optional exaggeration
    """
    args = [Shape.wrap(shape), list([Shape.wrap(i) for i in locus]), Shape.wrap(radius), Shape.wrap(exaggerate)]
    return Shape(stdlib.repel(
        args[0].ptr,
        tvec3(*[a.ptr for a in args[1]]),
        args[2].ptr,
        args[3].ptr))
示例#21
0
def taper_xy_z(shape, base, height, scale, base_scale=1):
    """ Tapers a shape in the xy plane as a function of z
        width = base-scale at base
        width = scale at base + [0 0 height]
    """
    args = [Shape.wrap(shape), list([Shape.wrap(i) for i in base]), Shape.wrap(height), Shape.wrap(scale), Shape.wrap(base_scale)]
    return Shape(stdlib.taper_xy_z(
        args[0].ptr,
        tvec3(*[a.ptr for a in args[1]]),
        args[2].ptr,
        args[3].ptr,
        args[4].ptr))