/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.awt.geom.Point2D;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	static class CPoint extends Point2D.Double
	{
		int id;
		double theta;
		CPoint prev, next;
		
		public CPoint(int id, double x, double y)
		{
			super(x, y);
			this.id = id;
			theta = Math.atan2(y, x);
			if(theta < 0) theta = 2*Math.PI + theta;
		}
	
		public String toString()
		{
			return String.format("%d : (%f,%f) : %f [(%f,%f) : (%f,%f)]", id, getX(), getY(), theta, prev.getX(), prev.getY(), next.getX(), next.getY());
		}
	}
	
	public static void main(String[] args)
	{
		double[][] coords = {{-0.708, 0.707, 0.309, -0.951, 0.587, -0.809},
				               {1, 0, 0, 1, -1, 0, 0, -1, 0.708, -0.708}};
		
		double areaSum = 0;

		List<CPoint> pts = new ArrayList<>();
		for(int i=0; i<coords.length; i++)
		{
			List<CPoint> poly = new ArrayList<>();
			for(int j=0; j<coords[i].length; j+=2)
			{
				poly.add(new CPoint(i, coords[i][j], coords[i][j+1]));
			}
			
			poly.sort((a, b) -> Double.compare(a.theta, b.theta));
			pts.addAll(poly);
			
			int n = poly.size();
			for(int j=0; j<n; j++)
			{
				poly.get(j).prev = poly.get((j + n - 1) % n);
				poly.get(j).next = poly.get((j + 1) % n);				
			}
			
			areaSum += area(poly);
		}		
				
		pts.sort((a, b) -> Double.compare(a.theta, b.theta));
				
		List<Point2D> intersections = new ArrayList<>();
		int n = pts.size();
		for(int i=0, j=n-1; i<n; j=i++)
		{
			if(pts.get(j).id != pts.get(i).id)
			{
				intersections.add(intersect(pts.get(j), pts.get(j).next, pts.get(i).prev, pts.get(i)));
			}
		}

		double areaInt = area(intersections);
		double iou = areaInt/(areaSum - areaInt);
		System.out.println(iou);
	}

	static double area(List<? extends Point2D> poly)
	{
		double area = 0;
		for(int i=0, j=poly.size()-1; i<poly.size(); j=i++)
			area += (poly.get(j).getX() * poly.get(i).getY()) - (poly.get(i).getX() * poly.get(j).getY());
		return Math.abs(area)/2;
	}

	// https://r...content-available-to-author-only...e.org/wiki/Find_the_intersection_of_two_lines#Java
	static Point2D intersect(Point2D p1, Point2D p2, Point2D p3, Point2D p4)
	{
	  double a1 = p2.getY() - p1.getY();
	  double b1 = p1.getX() - p2.getX();
	  double c1 = a1 * p1.getX() + b1 * p1.getY();
	
	  double a2 = p4.getY() - p3.getY();
	  double b2 = p3.getX() - p4.getX();
	  double c2 = a2 * p3.getX() + b2 * p3.getY();
	
	  double delta = a1 * b2 - a2 * b1;
	  return new Point2D.Double((b2 * c1 - b1 * c2) / delta, (a1 * c2 - a2 * c1) / delta);    
	}
}