Skip to content

Instantly share code, notes, and snippets.

@AstraLuma
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save AstraLuma/c6c1fa2065b63b7e3352 to your computer and use it in GitHub Desktop.

Select an option

Save AstraLuma/c6c1fa2065b63b7e3352 to your computer and use it in GitHub Desktop.
Antimony: Fillet, straight, 90deg
# ANEX-SPEC: 1
# ANEX-ID: astronouth7303@gmail.com/fillet-90-straight
# ANEX-VERSION: 1.0
# ANEX-AUTHOR: Jamie Bliss <astronouth7303@gmail.com>
# ANEX-CATEGORY: Routing
# ANEX-TAGS: routing, fillet
# ANEX-DESC: A 90deg straight-line fillet primitve suitable for union or subtraction
"""
A primitive for fillets. Union for interior corners; subtract with exterior ones.
Runs the fillet from (`x0`, `y0`, `z0`) to (`x1`, `y1`, `z1`) with radius `r`.
`a` is the angle of the rotation of the fillet. Sorry, there's no easy way to describe it.
"""
import math
import fab
title('Fillet (Straight, 90)')
input('x0', float)
input('y0', float)
input('z0', float)
input('x1', float)
input('y1', float)
input('z1', float)
input('r', float)
input('a', float)
length = math.sqrt((x1-x0)**2 + (y1-y0)**2 + (z1-z0)**2)
theta = math.atan2(y1-y0, x1-x0)*180/math.pi
phi = math.acos((z1-z0)/length)*180/math.pi
#output('length', length)
#output('theta', theta)
#output('phi', phi)
tri = fab.shapes.triangle(r, 0, 0, r, r, r)
circle = fab.shapes.circle(0, 0, r)
flat = tri & ~circle
flat = fab.shapes.origin_xy(flat, r, r, 0, 0)
#flat = fab.shapes.iterate_polar(flat, 0, 0, 4)
fillet = fab.shapes.extrude_z(flat, 0, length)
fillet = fab.shapes.rotate_z(fillet, a, 0, 0)
fillet = fab.shapes.rotate_y(fillet, -phi, 0, 0)
fillet = fab.shapes.rotate_z(fillet, theta, 0, 0)
fillet = fab.shapes.translate(fillet, x0, y0, z0)
output('shape', fillet)
# UI
fab.ui.point(x0, y0, z0)
fab.ui.point(x1, y1, z1)
fab.ui.wireframe([(x0, y0, z0), (x1, y1, z1)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment