16. The area of a triangle ABC can be calculated by: where AB is the vector from...
Question:
16. The area of a triangle ABC can be calculated by:
where AB is the vector from vertex A to vertex B and AC is the vector from vertex A to vertex C. Write a user-defined MATLAB function that determines the area of a triangle given its vertices’ coordinates. For the function name and arguments, use [Area] = TriArea(A,B,C). The input arguments A, B, and C are vectors, each with the coordinates of the corresponding vertex. Write the code of TriArea such that it has two subfunctions—one that determines the vectors AB and AC and another that executes the cross product. (If available, use the user-defined functions from Problem 15). The function should work for a triangle in the x-y plane (each vertex is defined by two coordinates) or for a triangle in space (each vertex is defined by three coordinates). Use the function to determine the areas of triangles with the following vertices:
(a) , ,
(b) , , a = 3i + 11j A = 1, 2 B =
Step by Step Answer: