I recently came across a very interesting post by the Italian programmer Emanuele Feronato where he describes a useful algorithm to test if a point is inside an arbitrary square.
Although the code is written in AS3 it's easy enough to understand and should easily port to Lua.
http://www.emanueleferonato.com/2012/03/09/algorithm-to-determine-if-a-point-is-inside-a-square-with-mathematics-no-hit-test-involved/Hopefully this might prove useful to someone.
Jon...
WhiteTree Games - Home, home on the web, where the bits and bytes they do play!
#MakeABetterGame! "Never give up, Never
NEVER give up!" -
Winston Churchill