Created
December 9, 2014 18:30
-
-
Save jwo/9a34535993686e6edd5f to your computer and use it in GitHub Desktop.
Code in a book. Author must have been like "I'mma gonna drop this right here."
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(Line *)lineAtPoint:(CGPoint)p | |
{ | |
for (Line *l in self.finishedLines){ | |
CGPoint start = l.begin; | |
CGPoint end = l.end; | |
for (float t=0.0; t<=1.0; t+= 0.05){ | |
float x = start.x + t * (end.x - start.x); | |
float y = start.y + t * (end.y - start.y); | |
if (hypot(x - p.x, y - p.y) < 20.0){ | |
return l; | |
} | |
} | |
} | |
return nil; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment