Confirming That A point Exist In Triangle
I have been assigned to make the following program in java, but frankly, I couldn't understand what is it asking in the following statement.
" Write a function to compute the distance between two points and use it to develop another function that will compute the area of the triangle whose vertices are A(x1,y1), B(x2, y2), and C(x3, y3). Use these functions to develop a function that returns a value 1 if the point (x, y) lines inside the triangle ABC, otherwise a value 0. "
Can someone help me to simply explain this and tell the step-wise process to make program? I will make a program according to your suggestions.
-
Write a function to compute the distance between two points
-
Use it to develop another function that will compute the area of the triangle whose vertices are A(x1,y1), B(x2, y2), and C(x3, y3).
-
Use these functions to develop a function that returns a value 1 if the point (x, y) lines inside the triangle ABC, otherwise a value 0.
I am assuming you know how to compute the distance between 2 points.
((A[0]-B[0])^2+(A[1]-B[1])^2)^0.5
Next you can use Heron's Formula to calculate the area of the triangle.
Finally you need to check if a point is contained in the triangle. For which you can use any of the solutions here: How to determine if a point is in a 2D triangle?