HW040
Math 2984 - Fall 2017
Intro to Mathematical Problem Solving


TASK: Write a function that computes the area of a quadrilateral, by using a function that computes the area of a triangle.


COMMENT: A "quadrilateral" is any polygon with four sides. If we label the vertices of the quadrilateral as A, B, C, D, then we can imagine dividing the quadrilateral into two triangles. It should be obvious that the area of the quadrilateral is the sum of the areas of the triangles.

        A--------D
         \       |
          \      |
           \     C
            \   /
             \ /
              B
      
Here is a sample quadrilateral. A counterclockwise ordering of the vertices is A, B, C, D.

        A--------D
         \  *    |
          \    * |
           \     C
            \   /
             \ /
              B
      
We could split the quadrilateral into two triangles by connecting A and C. Counterclockwise orderings of the triangle vertices are then (A,B,C) for triangle 1, and (A,C,D) for triangle 2.

I have written a function that computes the area of a triangle, assuming that the user has created a list of the x and y coordinates of the vertices, using counter clockwise order.

        function area = triangle_area ( xlist, ylist )
      

You need to write a new function, of the form

        function area = quadrilateral_area ( xlist, ylist )
      
Your function will use my function triangle_area() to do its task.


INSTRUCTIONS: First, be sure to copy the triangle_area.m file to your MATLAB directory.

        Your function could have the following outline:

        The function header

          The input xlist and ylist contain coordinates for A, B, C, and D.

          Create xlist1 and ylist1, which contain the cooridinates for A, B, C.
          Compute area1, the area of triangle 1.

          Create xlist2 and ylist2, which contain the cooridinates for A, C, D.
          Compute area2, the area of triangle 2.

          area = area1 + area2;
          return
        end
      


CHECK:For the quadrilateral with

        xlist = [ 0, 7, 9, 8 ]
        ylist = [ 6, 1, 3, 5 ]
      
the statement
        area = quadrilateral_area ( xlist, ylist )
      
should return an area of 19.5.


SUBMIT: Because it's a function, your file should be named "quadrilateral_area.m". Your file should begin with:

        % quadrilateral_area.m
        % YOUR NAME
        % This script (describe what it does)