Well, my first day in full-time employment went pretty well. I may have previously mentioned my cadetship thing in the military-industrial complex - the idea was that when I graduated, they would hire me, assuming they liked my work.
Well I've graduated, and they liked my work, so now I'm a permanent employee at BAE Systems Australia, doing software engineering.
I'm going to be stuck on a reasonably interesting demonstration project once the contract gets under way - some of the programming I was doing as a cadet is associated, so I spent the first day debugging an issue associated with an application I'd been writing as a cadet. Finally got it nailed to the floor. Much as it's famous last words, I think the program in question is now lacking in major bugs, which makes me pretty happy.
The program is, at the moment, basically just a map. It loads up maps in a particular format, and then renders them. Pretty simple, right?
Except that these are high-resolution maps of the entire world, stored in a vector format. And I'm rendering in three projections (planeterre, mercator, gnomonic). And this needs to be pretty close to real time.
Turns out that calling six trig functions for something on the order 2 million points is really slow, so there's a variety of optimisations so that I'm only projecting the points that I need to. Unfortunately, that makes things a helluva lot more complicated. That's where the bug came in. For some reason, in the gnomonic projection, if you kept going north, over the north pole, to a latitude of ~-170 degrees (That is, longitude 180, latitude 80, upside down), everything on screen would vanish. -180 and 170 degrees had the same problem. This would occur no matter what your longitude was.
Turns out that the way I was calculating the bounding box we were using to determine which points needed reprojecting meant that when the map was 'flipped' like that the bounding box was inside out - the calculated top left corner was basically the bottom right corner, and vice versa. The problem would have kicked in the instant the centre of the map went over the poles, except that any case where you're over the top of the poles is specially handled, because otherwise you need the full range of longitude if you can see a pole.
Basically the upshot of all of this is that sometimes I wish we were living on the Discworld.
EDIT: Speaking of the gnomonic projection, I have awesome friends. At a friend's 21st semi-recently, at about 2 AM, we decided we had to solve a problem in projective geometry that was causing me issues in work. Our approach was to get out a globe of the Earth, a translucent plastic lid, a Yu-Gi-Oh card, and a torch, and a whiteboard marker, and use them all together in a devilish scheme to determine how a rectangle projects onto a sphere under the gnomonic projection.
None of us had had a single drop of alcohol.
Copyright © 2018 BYOND Software. All rights reserved.