This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |