Math Error vs Code Error

There’s a fractal I’ve been wanting to make for a while. And the other week I woke up with a flash of insight and coded it, and it looked like this:

Initial Fractal
Initial Fractal

And I was really happy, until I realized it wasn’t the fractal that I’d meant to make. Oops. So I revisited it and remembered some ancient trigonometry… and it didn’t work.

So I checked my trig. And then rechecked it. And then redid it completely. Got infuriatingly close. Checked some more – wondered why the lines that I thought would be pointing up were pointing down, and vice versa.

Eventually, I stared in complete bafflement at a line that should have had an 18 degree angle to the x-axis, but was more like 45. Stared at my code. At the line.

Checked the API. Realized I should have been using radians. Kicked myself repeatedly.

My math had probably been right all along – it was just so easy to doubt my ability that I kept doubting myself, rather than debugging.

Anyway, now I have a pretty fractal. And a little more confidence in trig!

Snowflake Fractal
Snowflake Fractal

Leave a Reply