Nerd Sniping

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Nerd Sniping

Post by sliptonic »

Nothing serious here. This is just for fun.

I got distracted and wasted a lot of time learning about Rose Engine Lathes, Guilloche patterns, and Spirographs.

This video is particularly cool:
phpBB [video]


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

There's a more parametric version attached which adds an object to the tree inside an existing Path job.
Unfortunately, I quickly got out of my depth on the math. Anyone want to take a stab at improving this? :D

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.
Attachments
rose2.FCMacro
(3.42 KiB) Downloaded 29 times
RatonLaveur
Posts: 991
Joined: Wed Mar 27, 2019 10:45 am

Re: Nerd Sniping

Post by RatonLaveur »

Trippy...thank you for sharing.

My brain connected it immediately to this:
https://youtu.be/ds0cmAV-Yek
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Nerd Sniping

Post by Kunda1 »

There is something very hypnotic/alpha-brainwave inducing about watching the long strokes of the Spirograph machine. Trippy indeed!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
quick61
Veteran
Posts: 3803
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: Nerd Sniping

Post by quick61 »

That kind of puts me in mind of this - https://jeffeb3.github.io/sandify/ that provides the gcode for something like this -
phpBB [video]
This post made with 0.0% Micro$oft products - GOT LINUX?
Post Reply