Not an official ACM page
[Problem 2 | 1997 East-Central problem set | Ed's programming contest problem archive | my home page]

ACM East Central Region
1997 Regional Programming Contest

Problem 1 - Polygon Puzzler

We define a simple polygon as an area enclosed by endpoint-connected line segments such that no line segment intersects another (except for adjoining segments at their endpoints). A simple polygon can thus be defined by an ordered list of its vertices (the endpoints of the enclosing line segments). A planar polygon is a polygon whose vertices all lie in the same plane.

For this problem you are asked to compute the area of a simple planar polygon oriented in three space. That is, although the vertices of the polygon lie in some two-dimensional plane, the vertices are specified in three-dimensional Cartesian coordinates.

Input

The input will consist of an ordered sequence of coordinates for the vertices of the polygon. Each line of the input will contain the three-dimensional Cartesian coordinates for a single vertex in the order x, y, z. The values for the x, y, z components will be separated by a single space. Input values should be considered to be double precision floating point and may be positive or negative. The coordinates of the final line of input input will be the same as the coordinates on the first line of input. No polygon will have more than 1024 vertices.

Output

The output should be the area of the polygon specified by the input and should be rounded to the nearest 1/1000 (i.e., three places after the decimal point should be printed).

Sample Input

1.401117996399998e+00 1.509291958378880e-01 1.186959898555237e-01
1.918738650437130e-01 1.067473024933127e+00 9.075713530920345e-01
1.401117996399998e+00 -1.509291958378880e-01 -1.186959898555237e-01
-1.918738650437130e-01 -1.067473024933127e+00 -9.075713530920345e-01
-1.401117996399998e+00 1.509291958378880e-01 1.186959898555237e-01

Output for the Sample Input

4.000

This page maintained by Ed Karrels.
Last updated December 10, 1999