Project Euler #102: Triangle containment

  • + 1 comment

    I don't know why everybody here makes this problem too complicated by using Interior Triangle (Convex Hull) or Barycentric Coordinate. Just think about highschool math.

    Hint: Calculate the area S of ABC, OAB, OAC and OBC. If O is inside ABC, then S_ABC = S_OAB + S_OAC + S_OBC.

    Trick: To avoid numerical errors, use abs(S_ABC - S_OAB - S_OAC - S_OBC) < 1e-9 instead of S_ABC == S_OAB + S_OAC + S_OBC