00:01
Hello, for problem 27, you're going to be asked to write a program that prompts the user for the x and y coordinates of a point and then determines whether or not that point is within the triangle shown in the figure.
00:18
So we'll start by getting x1 and y1, which are the coordinates of the point entered by the user.
00:25
And then we will define the corners of the original triangle x2y2 which is 0 .0, x3y3, which is 200, and x4y4, which is 0100.
00:40
Now to determine whether or not the point is inside the triangle, we're going to split the triangle into triangles.
00:50
So we'll take the user inputted point and two other points on the triangle.
00:55
The given triangle and calculate the area of that triangle.
01:00
And if we do that for each set of two points on the original triangle, that should be the same as the area of the original triangle.
01:09
So essentially we're using the user generated point to split our original triangle into three additional triangles.
01:18
And if we end up with the areas being equal, then the point must be inside.
01:23
If the areas are not equal, then the point will be outside of the original triangle...