Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Triangle: Wailing and Gnashing of Teeth

📅 2010-Jul-26 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

Studying code written by others can be highly educational. And a lot of times fun too. Here is a comment found in the triangle.c source file of the Triangle program:

/*        This routine does not check either of these preconditions, and     */
/*  it is the responsibility of the calling routine to ensure that they are  */
/*  met.  If they are not, the streets shall be filled with wailing and      */
/*  gnashing of teeth.                                                       */
void flip(struct mesh *m, struct behavior *b, struct otri *flipedge)
{ /***/ }

Triangle is the fastest 2D Delaunay triangulation program, written entirely by just one person, Prof. Jonathan Shewchuk. It is probably one of the most greatest feats of programming in the field of Computational Geometry. I doubt there is anyone who is unimpressed by the code of Triangle or anyone (other than Shewchuk) who can claim to have understood it entirely! 😁