naming is hard
I often have trouble giving meaningful concise names to variables in the programs I write, perhaps because, until I reach for the keyboard, my thinking is largely nonverbal. I suspect that it would be less of a problem for someone more exposed to the accumulated lore of programmer culture; though perhaps not in this case:
I’m thinking of breaking up this process into multiple rounds, to obtain increasing degrees of geometric continuity. The initial nodes would coincide with the input dots but have no defined theta (tangent angle) or kappa (curvature); the first round of replacements determines theta for G¹ continuity, the next round determines kappa (the first derivative of theta) for G² continuity — and subsequent rounds may seek higher degrees of continuity by matching further derivatives.
This means that the node object, instead of exactly two fields called theta and kappa, should have a list of theta and its known derivatives (one more than the current replacement-round needs), and I’m at a loss for a good name for this list.
FCC cube generator
I could have used this a week ago.
def fccstack():
newlimit = 0
while True:
oldlimit = newlimit
newlimit += 1
# extend z
for x in xrange(oldlimit):
for y in xrange((x+oldlimit)&1, oldlimit, 2):
yield (x,y,oldlimit)
# extend y
for x in xrange(oldlimit):
for z in xrange((x+oldlimit)&1, newlimit, 2):
yield (x,oldlimit,z)
# extend x
for y in xrange(newlimit):
for z in xrange((y+oldlimit)&1, newlimit, 2):
yield (oldlimit,y,z)
g = fccstack()
for dummy in xrange(512):
p,q,r = g.next()
print "%d %d %d\t%d" % (p,q,r, p+q+r)
This lists coordinates of sites in a face-centred cubic lattice, filling the smallest cube that contains the number of sites required.
in which I curse my lack of omniscience
I want to push several hundred greyscale images through a threshold filter, so that an output pixel is black or white according to whether the corresponding input pixel is less or more than 1/2 bright. (My goal is a ‘woodcut’ effect.)
ImageMagick can apparently do this with one command, but I lack a library that it needs.
GIMP has a menu command with this function, but to do it from a script it seems I’d need to learn Scheme.
I could write a program using Python Imaging Library (which I’ve used to output most of my mathematical designs in recent years), but so far in RTFM I can’t tell how to, y’know, access the pixels it reads in. Later: Found a better FM.
Wish me luck.
do you speak my calendar?
In MacBSD, the command cal 9 1752 shows the shortening of that month in the British Empire. If I reinstall MacOS and choose Italian as its default language, will the shift show up instead in October 1582?
off by one
A look at 404s in my HTTP log revealed a bug in my math pix page, which in two places chooses randomly from families of images. I didn’t know that the PHP function rand(nmin,nmax) is inclusive at both ends.
pass the time by tracing rays
I had assumed that Pixar did not use ray-tracing because it could not provide certain desired lighting effects. Now Dad tells me that Monsters University is Pixar’s first ray-traced feature, which implies that the speed wasn’t available until now.
u-shape-it
Hm, Shapeways has an API. If I were a skilled Web programmer I’d make a page where you can choose the size and frequencies of a Klein bagel model …