Previous | Next --- Slide 67 of 71
Back to Lecture Thumbnails
janeqi417

when we use this method to check whether a point is inside the triangle, the sequence of the point is also important, right? I mean, the orientation that we compute the E.

keenan

@janeqi417 Yes, excellent observation. If you reverse the order of the points, your test might break. Question: given three points in an arbitrary order, what's a little algorithm you can run to (i) decide whether they are in (say) counter-clockwise order and (ii) update the ordering if not?

janeqi417

@Keenan We can use cross product of two vectors (V1-V0) and (V2-V0) to check whether they are in clockwise or counter clockwise. If the cross product is positive, means that the three points are in counter-clockwise. If the cross product is negative, the three points are in clockwise. If the three points are in clockwise, we can then swap V1 and V2. Is this right?

keenan

@janeqi417 Yep, that's it! Terrific answer; very simple, and simple to implement.