search
Saturday, 2014 May 10, 16:30 — curve-fitting, neep-neep

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.

Saturday, 2014 February 1, 18:32 — mathematics, neep-neep

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.

Friday, 2014 January 24, 22:23 — neep-neep

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.

Wednesday, 2013 December 4, 13:03 — astronomy, history, neep-neep

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?

Sunday, 2013 December 1, 22:08 — me!me!me!, neep-neep

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.

Saturday, 2013 October 26, 14:41 — language, spam, technology

limited voice recognition?

When I answer the ’phone, I generally say either “Yes?” or “Good day/evening, Sherwoods” rather than “Hello.” With cold-callers I often don’t get a response to that; I pause and try a variation or two of “Is someone there?” before the caller speaks up with a bewildered “Hello?”.

Does their robo-dialer wait for a “Hello” before prompting the human that it has found a live line?

Sunday, 2013 June 23, 16:06 — cinema, neep-neep

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.

« Previous PageNext Page »