Curved Lines
Tim Bray is playing with his new Android Phone by writing a phone app and blogging his progress. It’s an instructive exercise, even if you aren’t very interested in this particular phone right now. Some things I learned from Part VI:
- Good minds talk about impressive things, but people of the first rank don’t mind talking about unimpressive things. The thrust of this article — let’s face it — is high school geometry. Bray is Director of Web Technologies at Sun and one of the top people in Web/XML technology. He’s not worrying what you’ll think, he’s worrying about getting the problem solved.
- The problem in this case is drawing an aesthetically curved line between two points. (The points are places on a map; drawing a straight line might often obscure things you want to see — such as the road you want to take.)
- Bray, needing a curve, reaches for a circular arc. My own tendency, these days, would be to grab a Bezier curve. I’m not sure which is better, though the Bezier is clearly more flexible, and I suspect that for points widely separated on the screen the arc will stray too far from the centerline. But I’d love to know why Bray reached for the arc in the first place.
- Bray has a reflex to avoid extra floating point computation and is at some pains to optimize this code, even though it turns out to be plenty fast enough. Nice to know I’m not alone in this.