Пример #1
0
RADIUS = 5             ## Outer radius of the spiral
dtheta = 2*math.pi/N    ## Change in heading after each step
dx = RADIUS * dtheta    ## Forward movement during each step
dr = -0.5/N             ## Change in radius with each step

t = ExtruderTurtle()

t.name("hair-pillar.gcode")
t.setup(x=150, y=150)
t.set_density(0.07) # 0.05
t.rate(500)

radius = RADIUS
while radius>0:
    t.forward(dx)
    t.right(dtheta)
    radius += dr
    dx = radius * dtheta

for l in range(200):
    t.extrude(0.1)
    t.dwell(200)
    t.lift(0.1) # 0.1

t.penup()
t.forward(80)
t.right(math.pi/2)
t.forward(80)
t.right(math.pi)
t.lift(-20)
t.pendown()
Пример #2
0
t = ExtruderTurtle()

## Set up the turtle
t.name("nonplanar-vase.gcode")
t.setup(x=100, y=100)
t.set_density(0.05)
t.rate(500)

## Draw a spiral base
dr = 0.5 / 60
base_rad = 0
base_dx = 0
while base_rad < RADIUS:
    t.forward(base_dx)
    t.right(2 * math.pi / 60)
    base_rad += dr
    base_dx = base_rad * 2 * math.pi / 60

## First few layers "bulding up" the oscillations
for l in range(20):
    prop = l / 20
    total_prop = l / LAYERS
    for k in range(N):
        angle = k * dtheta
        t.forward_lift(
            dx,
            PERIODS * AMPLITUDE * prop * math.sin(PERIODS * angle) / N)
        t.right(dtheta)
        t.lift(0.25 / N)
    t.left(math.pi / 2)
NUM_SIDES = 5
LAYERS = 200
dtheta = 2 * math.pi / NUM_HAIRS
dx = DIAMETER * math.sin(dtheta / 2)

t = ExtruderTurtle()

## Set up the turtle
t.name("flex-circle.gcode")
t.setup(x=100, y=100)
t.rate(FEEDRATE)
t.set_density(EXT_DENSITY)

for l in range(LAYERS):
    for k in range(NUM_HAIRS):
        t.right(dtheta)
        t.forward(dx)
        t.left(HAIR_ANGLE)
        t.forward(HAIRLENGTH)
        t.dwell(50)
        t.forward(-2 * HAIRLENGTH)
        t.dwell(50)
        t.forward(HAIRLENGTH)
        t.right(HAIR_ANGLE)

    ## Move to the next layer
    t.lift(LAYER_HEIGHT)

## Save to a GCODE file
t.finish()
from extruder_turtle import ExtruderTurtle
import math

t = ExtruderTurtle()

t.name("stretchy-material.gcode")
t.setup(x=100, y=100)
t.rate(900)
t.set_density(0.05)

for l in range(5):
    for r in range(5):
        for n in range(4):
            t.forward(10)
            t.right(math.pi / 2)
            t.forward(4)
            t.left(math.pi / 2)
            t.forward(2)
            t.left(math.pi / 2)
            t.forward(8)
            t.right(math.pi / 2)
            t.forward(2)
            t.right(math.pi / 2)
            t.forward(4)
            t.left(math.pi / 2)
        sgn = (-1)**(r % 2)
        t.forward(10)
        t.left(math.pi / 2 * sgn)
        t.forward(14)
        t.left(math.pi / 2 * sgn)
    t.left(math.pi / 2)
Пример #5
0
from extruder_turtle import ExtruderTurtle
import math

t = ExtruderTurtle()

t.name("euler-spiral.gcode")
t.setup(x=100, y=100)
t.rate(700)
t.set_density(0.5)

length = 0
dl = 5

for i in range(200):
    length += dl
    t.move(dl)
    t.right(2 * math.pi * length * dl / 10)
    dl = 5 / length

t.finish()
Пример #6
0
t.setup(x=100, y=100)
t.rate(500)

t.set_density(0.06)
for l in range(50):
    x = 5 * (l % 10)
    y = 5 * (l % 10)
    theta = math.atan(y / (50 - x))
    r = math.sqrt((50 - x)**2 + y**2)
    for i in range(3):
        t.forward(50)
        t.left(math.pi / 2)
        t.forward(50)
        t.left(math.pi * 3 / 4)
        t.forward(50 * math.sqrt(2))
        t.left(math.pi * 3 / 4)
        t.lift(0.3)
    t.lift(-0.2)
    t.set_density(0.03)
    t.forward(x)
    t.left(theta)
    t.forward(r)
    t.forward(-r)
    t.right(theta)
    t.forward(-x)
    t.lift(0.2)
    t.set_density(0.06)
    t.pendown()

t.finish()
from extruder_turtle import ExtruderTurtle
import math
import random

t = ExtruderTurtle()

t.name("random-cone.gcode")
t.setup(x=100, y=100)
t.rate(700)
t.set_density(0.02)

for l in range(80 * 7):
    t.forward(20 - l * 20 / (80 * 7))
    t.right(2 * math.pi / 7 + math.pi * random.random() / 500)
    t.lift(0.3 / 7)
    t.lift(1)
    t.extrude(0.8)
    t.lift(-1)
    t.dwell(200)

t.finish()
Пример #8
0
dx = DIAMETER*math.sin(dtheta/2)
n = 1

t = ExtruderTurtle()

## Set up the turtle
t.name("not-a-cardioid.gcode")
t.setup(x=100, y=100)
t.rate(700)

for l in range(50):
    ## Draw a circle
    t.set_density(0.07)
    t.left(dtheta/2)
    for k in range(N):
        t.right(dtheta)
        t.move(dx)
    t.right(dtheta/2)
    
    ## Draw several chords
    for i in range(10):
        t.dwell(100)
        t.set_density(0.03)
        angle = n*dtheta/2
        t.right(angle)
        t.move(DIAMETER*math.sin(angle))
        t.right(angle)
        ## Point n is joined by a line segment to point 2n
        n = (3*n) % N

    ## Move to the next layer
Пример #9
0
GENS = 5
sidelength = 50 / 2**GENS

t = ExtruderTurtle()

t.name("hilbert.gcode")
t.setup(x=100, y=100)
t.set_density(0.05)
t.rate(800)

for g in range(GENS):
    new_instr = ""
    for r in instr:
        new_instr += sub_rules[r]
    instr = new_instr

for l in range(10):
    for r in instr:
        if r == "F": t.forward(sidelength)
        elif r == "+": t.right(math.pi / 2)
        elif r == "-": t.left(math.pi / 2)
    t.lift(0.3)
    for r in reversed(instr):
        if r == "F": t.backward(sidelength)
        elif r == "+": t.left(math.pi / 2)
        elif r == "-": t.right(math.pi / 2)
    t.lift(0.3)

t.finish()
t = ExtruderTurtle()

## Set up the turtle
t.name("gappy-prism.gcode")
t.setup(x=100, y=100)
t.rate(700)

for l in range(LAYERS):
    ## Draw a pentagon
    for k in range(NUM_SIDES):
        ## Draw one side, with a randomly chosen gap
        x = (SIDELENGTH-GAPLENGTH) * random.random()
        t.move(x)
        ## Move out of the way in order to break the plastic strand
        t.penup()
        t.right(math.pi/2)
        t.move(SIDELENGTH)
        t.dwell(50)
        t.left(math.pi)
        t.move(SIDELENGTH)
        t.right(math.pi/2)
        ## Skip over the gap and continue drawing the side
        t.move(GAPLENGTH)
        t.pendown()
        t.move(SIDELENGTH-GAPLENGTH-x)
        t.right(2*math.pi/NUM_SIDES)

    ## Move to the next layer
    t.lift(0.3)

## Save to a GCODE file
dtheta = 2*math.pi/N
dx = DIAMETER*math.sin(dtheta/2)

t = ExtruderTurtle()

## Set up the turtle
t.name("dreamcatcher.gcode")
t.setup(x=100, y=100)
t.rate(700)

for l in range(50):
    ## Draw a circle
    t.set_density(0.07)
    t.left(dtheta/2)
    for k in range(N):
        t.right(dtheta)
        t.forward(dx)
    t.right(dtheta/2)

    ## Draw a random chord on the circle
    t.dwell(100)
    t.set_density(0.03)    
    rand_angle = dtheta*random.randint(1,N)/2
    t.right(rand_angle)
    t.forward(DIAMETER*math.sin(rand_angle))
    t.right(rand_angle)

    ## Move to the next layer
    t.lift(0.3)

## Save to a GCODE file
Пример #12
0
t = ExtruderTurtle()

## Set up the turtle
t.name("braille-ca.gcode")
t.setup(x=100, y=100)
t.rate(FEEDRATE)
t.set_density(EXT_DENSITY)

ca = [0] * NUM_SIDES
ca[0] = 1
on_states = [1, 2, 3, 4]  # Wolfram's "Rule 30"

for l in range(LAYERS):
    for k in range(NUM_SIDES):
        t.right(dtheta)
        t.forward(dx)
        if ca[k] == 1:
            t.left(BUMP_ANGLE)
            t.forward(BUMPLENGTH)
            t.forward(-BUMPLENGTH)
            t.right(BUMP_ANGLE)
        t.lift(LAYER_HEIGHT / NUM_SIDES)

    ## Update cellular automaton
    if l % 3 == 2:
        new_ca = [0] * NUM_SIDES
        for i in range(NUM_SIDES):
            state_num = ca[(i - 1) % NUM_SIDES] * 4 + ca[i] * 2 + ca[(i + 1) %
                                                                     NUM_SIDES]
            if state_num in on_states: new_ca[i] = 1
t.setup(x=100, y=100)
t.rate(500)

for l in range(30):
    ## Track progress
    vert_prop = l / 30

    ## Draw a seven-pointed star
    for k in range(7):
        ## Each line is slightly parabolically curved
        ## The bottom layer is completely flat, but
        ## subsequent layers are increasingly curved
        for x in range(-25, 26):
            horiz_prop = x / 25
            t.forward_lift(1, -vert_prop * horiz_prop * 0.3)
        t.right(6 * math.pi / 7)

    ## Move to the next layer
    t.lift(0.15)

t.penup()
for k in range(7):
    for x in range(-25, 26):
        horiz_prop = x / 25
        t.extrude(0.5)
        t.lift(2)
        t.extrude(-0.1)
        t.forward_lift(1, 4 - horiz_prop * 0.3)
        t.lift(-6)
    t.right(6 * math.pi / 7)
SIDELENGTH = 25
NUM_SIDES = 5
LAYERS = 100
dx = SIDELENGTH/(NUM_HAIRS+1)

t = ExtruderTurtle()

## Set up the turtle
t.name("furry-prism.gcode")
t.setup(x=100, y=100)
t.rate(FEEDRATE)
t.set_density(EXT_DENSITY)

for l in range(LAYERS):
    ## Draw a pentagon
    for k in range(NUM_SIDES):
        t.move(dx)
        for n in range(NUM_HAIRS):
            t.left(HAIR_ANGLE)
            t.move(HAIRLENGTH)
            t.move(-HAIRLENGTH)
            t.right(HAIR_ANGLE)
            t.move(dx)
        t.right(2*math.pi/NUM_SIDES)

    ## Move to the next layer
    t.lift(LAYER_HEIGHT)

## Save to a GCODE file
t.finish()
Пример #15
0
from extruder_turtle import ExtruderTurtle
import math

t = ExtruderTurtle()

t.name("complex-walk.gcode")
t.setup(x=100, y=100)
t.rate(700)

N = 75
period = 224
angle = 2 * math.pi / N

for l in range(30):
    for k in range(period + 1):
        t.forward(2)
        t.right(angle * k * (k - 1) / 2)
    t.lift(0.3)

t.finish()
Пример #16
0
t.name("evolving_snowflake.gcode")
t.setup(x=100, y=100)
t.rate(700)

for g in range(NUM_GENS):
    for l in range(40):
        progress = l/40
        gap_length = progress*sidelength/3
        long_length = (sidelength - gap_length)/2
        for r in instr:
            if r == "f":
                t.forward(long_length)
                t.left(math.pi/3)
                t.forward(gap_length)
                t.right(2*math.pi/3)
                t.forward(gap_length)
                t.left(math.pi/3)
                t.forward(long_length)
            elif r == "r":
                t.right(math.pi/3)
            elif r == "l":
                t.left(math.pi/3)
        t.lift(0.3)
    new_instr = ""
    for r in instr:
        new_instr += sub_rules[r]
    instr = new_instr
    sidelength = sidelength/3

t.finish()
Пример #17
0
N = 40  ## Number of subdivisions of one round-trip
radius = 20  ## Outer radius of the spiral
dtheta = 2 * math.pi / N  ## Change in heading after each step
dx = radius * dtheta  ## Forward movement during each step
dr = -0.5 / N  ## Change in radius with each step

t = ExtruderTurtle()

t.name("alien-tree.gcode")
t.setup(x=100, y=100)
t.set_density(0.07)  # 0.05
t.rate(500)

while radius > 0:
    t.forward(dx)
    t.right(dtheta)
    radius += dr
    dx = radius * dtheta

for l in range(50):
    t.extrude(0.1)
    t.dwell(100)
    t.lift(0.05)  # 0.1

for x in range(60):
    for l in range(10):
        t.extrude(0.1)
        t.dwell(100)
        t.lift(0.1)
    for n in range(5):
        t.forward(x / 4)
t = ExtruderTurtle()

## Set up the turtle
t.name("bumpy-prism.gcode")
t.setup(x=100, y=100)
t.rate(700)
t.set_density(0.07)

for l in range(LAYERS):
    ## Draw a pentagon
    for k in range(NUM_SIDES):
        ## Draw one side, with a randomly placed bump
        x = SIDELENGTH * random.random()
        t.move(x)
        t.left(BUMP_ANGLE)
        t.rate(100)
        t.move(BUMPLENGTH)
        t.dwell(50)
        t.move(-BUMPLENGTH)
        t.rate(700)
        t.right(BUMP_ANGLE)
        t.move(SIDELENGTH - x)
        t.right(2 * math.pi / NUM_SIDES)

    ## Move to the next layer
    t.lift(0.3)

## Save to a GCODE file
t.finish()