Skip to content

Instantly share code, notes, and snippets.

@CnrLwlss
CnrLwlss / circleObjective.py
Created January 19, 2013 13:51
Functions for packing N circles into a rectangle of width W and height H, together with a function for plotting solution and some example code fitting 13 circles into a square. http://cnr.lwlss.net/CircleObjectivesPython/ #python #opimisation #circle #packing #svg #function #closure
import random, numpy
def genGuess(N,W,H):
'''Generate sensible initial guess vector (random circle coordinates and radii)'''
z=numpy.zeros(3*N)
for i in xrange(0,N):
z[i*3]=random.random()*W
z[i*3+1]=random.random()*H
z[i*3+2]=0.001*min(W,H)+random.random()*(0.009*min(W,H))
return(z)
@tatarize
tatarize / zinglplotter.py
Created November 18, 2020 14:03
list(ZinglPlotter.linearize(Path(Circle(0,0,5000)))) # After doing an import. Also try with any other loaded paths.
from queue import Queue
from svgelements import *
"""
The Zingl-Bresenham plotting algorithms are from Alois Zingl's "The Beauty of Bresenham's Algorithm"
( http://members.chello.at/easyfilter/bresenham.html ).
In the case of Zingl's work this isn't explicit from his website, however from personal
correspondence "'Free and open source' means you can do anything with it like the MIT licence."
//
// Simplify.swift
// adapted from https://gist.github.com/yageek/287843360aeaecdda14cb12f9fbb60dc
// updated to work with Swift 5.9
//
// Simplification of a 3D-polyline.
// A port of https://github.com/hgoebl/simplify-java for Swift
//
//
// The MIT License (MIT)