Question: Problem 3.5. Compute the area of an arbitrary triangle An arbitrary tri- angle can be described by the coordinates of its three vertices: (r1, yl),

Problem 3.5. Compute the area of an arbitrary triangle An arbitrary tri- angle can be described by the coordinates of its three vertices: (r1, yl), (x2, y2), (r3, y3), numbered in a counterclockwise direction. The area of the triangle is given by the formula GT2y3 1342 11y3 + *3y1 +*12 12y1| Write a function t riangle_area(vertices) that returns the area of a triangle whose vertices are specified by the argument vertices, which is a nested list of the vertex coordinates. Make sure your implementation passes the following test function, which also illustrates how the triangle_area function works: def test triangle_area(): Verify the area of a triangle with vertices (0,0), (1,0), and (0,2). v1 = (0,0); v3 = (0,2) v2 = (1,0); [v1, v2, v3] vertices = expected computed = triangle area(vertices) tol = 1E-14 success = abs (expected computed)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
