13.07.2015 Views

5075 - Intersection of Two Prisms

5075 - Intersection of Two Prisms

5075 - Intersection of Two Prisms

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>5075</strong> - <strong>Intersection</strong> <strong>of</strong> <strong>Two</strong> <strong>Prisms</strong>Asia - Tokyo - 2010/2011Suppose that P 1 is an infinite-height prism whose axis is parallel to the z-axis, and P 2 is also an infinite-heightprism whose axis is parallel to the y-axis. P 1 is defined by the polygon C 1 which is the cross section <strong>of</strong> P 1 andthe xy-plane, and P 2 is also defined by the polygon C 2 which is the cross section <strong>of</strong> P 2 and the xz-plane.Figure I.1 shows two cross sections which appear as the first dataset in the sample input, and Figure I.2 showsthe relationship between the prisms and their cross sections.Figure I.1: Cross sections <strong>of</strong> <strong>Prisms</strong><strong>5075</strong> - <strong>Intersection</strong> <strong>of</strong> <strong>Two</strong> <strong>Prisms</strong> 1/5


Figure I.2: <strong>Prisms</strong> and their cross sections<strong>5075</strong> - <strong>Intersection</strong> <strong>of</strong> <strong>Two</strong> <strong>Prisms</strong> 2/5


Figure I.3: <strong>Intersection</strong> <strong>of</strong> two prismsFigure I.3 shows the intersection <strong>of</strong> two prisms in Figure I.2, namely, P 1 and P 2 .Write a program which calculates the volume <strong>of</strong> the intersection <strong>of</strong> two prisms.InputThe input is a sequence <strong>of</strong> datasets. The number <strong>of</strong> datasets is less than 200.Each dataset is formatted as follows.m nx 11 y 11x 12 y 12x 1m y 1mx 21 z 21x 22 z 22x 2n z 2nm and n are integers ( 3 m 100, 3 n 100) which represent the numbers <strong>of</strong> the vertices <strong>of</strong> the polygons,C 1 and C 2 , respectively.x 1i , y 1i , x 2j and z 2j are integers between -100 and 100, inclusive. (x 1i , y 1i ) and (x2j, z2j) mean the i-th and j-thvertices' positions <strong>of</strong> C 1 and C 2 respectively.The sequences <strong>of</strong> these vertex positions are given in the counterclockwise order either on the xy-plane or thexz-plane as in Figure I.1.You may assume that all the polygons are convex, that is, all the interior angles <strong>of</strong> the polygons are less than180 degrees. You may also assume that all the polygons are simple, that is, each polygon's boundary does notcross nor touch itself.The end <strong>of</strong> the input is indicated by a line containing two zeros.OutputFor each dataset, output the volume <strong>of</strong> the intersection <strong>of</strong> the two prisms, P 1 and P 2 , with a decimalrepresentation in a line.<strong>5075</strong> - <strong>Intersection</strong> <strong>of</strong> <strong>Two</strong> <strong>Prisms</strong> 3/5


None <strong>of</strong> the output values may have an error greater than 0.001. The output should not contain any other extracharacters.Sample Input4 37 23 30 23 14 20 18 14 430 230 122 122 215 230 813 142 88 513 521 721 918 1511 156 106 88 510 125 915 620 1018 123 35 510 310 1020 810 1510 84 4-98 99-99 -9999 -9899 97-99 99-98 -9899 -9996 990 0Sample Output4.7083333333333331680.0000000000005491.15000000000070.07600258.4847715655<strong>5075</strong> - <strong>Intersection</strong> <strong>of</strong> <strong>Two</strong> <strong>Prisms</strong> 4/5


Tokyo 2010-2011<strong>5075</strong> - <strong>Intersection</strong> <strong>of</strong> <strong>Two</strong> <strong>Prisms</strong> 5/5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!