Write a function to determine whether a point lies within a triangle (2D space).
Anonymous
I knew how to do this in 3D because I'd done it numerous times before, but my mind panicked and blanked and I couldn't figure out how to step back to 2D. I ended up doing it in 3D, which confused them but they let it slide. Basically, if you had triangle a,b,c and point p, you check to see if point p lies on the same side of each line (e.g. ab) as the third point (e.g. c). I did this by setting the z value of all vectors to 0 (since it was 2D space), taking the cross products abxap and abxac (for example) and seeing if the resulting vectors' z values had the same sign (both negative or both positive). There's a better way to do it in 2D though.
Check out your Company Bowl for anonymous work chats.