I got distracted and wasted a lot of time learning about Rose Engine Lathes, Guilloche patterns, and Spirographs.
This video is particularly cool:
I'd love to be able to engrave patterns like this, maybe on hard drive platters.
A very simple macro generates a raw path:
Code: Select all
#-----------------------------------------------------------------------
# spirograph.py
#-----------------------------------------------------------------------
import sys
import math
import Path
# Accept float command-line arguments R, r, and a.
# Draw a curve formed by rolling a smaller circle of radius r inside
# a larger circle or radius R. If the pen offset of the pen point in
# the moving circle is a, then the equation of the resulting curve
# at time t is
#
# x = (R+r)*cos(t) - (r+a)*cos(((R+r)*t)/r)
# y = (R+r)*sin(t) - (r+a)*sin(((R+r)*t)/r)
# Credits: idea suggested by Diego Nehab
# Reference: http://www.math.dartmouth.edu/~dlittle/java/SpiroGraph
# Reference: http://www.wordsmith.org/~anu/java/spirograph.html
sidecount = 96
rosewidth = 30
type = "e"
R = 8.0
r = R/sidecount
#r = 32.0/96.0
#a = 168.0/96.0
a = rosewidth/2
PathList = []
t = 0.0
if type == "h":
while t <= 10:
x = (R+r) * math.cos(t) - (r+a) * math.cos(((R+r)*t)/r)
y = (R+r) * math.sin(t) - (r+a) * math.sin(((R+r)*t)/r)
degrees = -math.degrees((R+r)/r)*t
c = Path.Command("G1 X{} Y{}".format(x,y))
PathList.append(c)
t += 0.001
else:
while t <= 10:
x = (R-r) * math.cos(t) + (r+a) * math.cos(((R-r)*t)/r)
y = (R-r) * math.sin(t) - (r+a) * math.sin(((R-r)*t)/r)
degrees = -math.degrees((R+r)/r)*t
c = Path.Command("G1 X{} Y{}".format(x,y))
PathList.append(c)
t += 0.001
p = Path.Path(PathList)
o = App.ActiveDocument.addObject("Path::Feature","mypath")
o.Path = p
Unfortunately, I quickly got out of my depth on the math. Anyone want to take a stab at improving this?
Ideally, the user could tweak and adjust a bunch of settings to achieve a satisfying pattern but control the center point and overall diameter explicitly to position it for engraving.
BTW, the title of this post comes from a relevant XKCD comic.