
28 Jun
2007
28 Jun
'07
12:04 p.m.
Paul Hudak wrote:
As an aside, looking at your code a bit closer, I see this:
(polygon [(x,y),(a,b),(x,y)])) where b = y + side * sin(pi/3) a = x + side * cos(pi/3)
Something is not right here -- you repeat (x,y) as a vertex. Probably the third vertex should be (x+side,y). Also, note that sin (pi/3) and cos (pi/3) are constants (namely 0.866... and 0.5, resp.).
Constant they may be, but it's still clearer in my opinion to write them like that. To factor them out as constants (except simply as an exercise in the practise of code refactoring) smacks of premature optimization to me. Jules