Created
September 3, 2012 00:42
-
-
Save kristenmills/3605927 to your computer and use it in GitHub Desktop.
Project Euler 102
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
def same_side p1, p2, p3, p4 | |
cp1 = cross_product p4-p3, p1-p3 | |
cp2 = cross_product p4-p3, p2-p3 | |
dot_product(cp1, cp2) >=0 | |
end | |
# is the point p in the triangle | |
def point_in_triangle p=Vector[0,0,0], a, b, c | |
same_side(p, a, b, c) && same_side(p, b, a, c) && same_side(p, c, a, b) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment