November 2nd, 2009

Square Spinner: a shape grammar

Below is an applet that I made for Terry Knight’s Inquiry into Computation class. The intent is to, in an AI kind of way, probe into the ability of computers to do what people are naturally really good at. In this case, given a set of lines, the code finds squares and rotates them by 45º. Considering the simplicity of the task and that it is a well defined task, the code was a real pain to write on account of lots of special cases.
Incidentally, everything is done in exact terms with zero margin for floating point errors. This is accomplished by storing points as pairs of elements in a quadratic field, Q of root D with D=2. This allows for 45º rotation while maintaining integer accuracy. (the coefficients are rational, so they have integer accuracy.)
All Java code is in this rar file

This work is licensed under GPL - 2009 | Powered by Wordpress using the theme aav1