poj2242

正弦定理+叉积

View Code
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

struct Point
{
    double x, y;
    Point operator -(const Point &b)
    {
        Point ret;
        ret.x = this->x - b.x;
        ret.y = this->y - b.y;
        return ret;
    }
}p1, p2, p0;

double xmult(Point a, Point b)
{
    return a.x * b.y - a.y * b.x;
}

double mol(Point a)
{
    return sqrt(a.x * a.x + a.y * a.y);
}

int main()
{
//    freopen("t.txt", "r", stdin);
    while (~scanf("%lf%lf%lf%lf%lf%lf", &p0.x, &p0.y, &p1.x, &p1.y, &p2.x, &p2.y))
    {
        Point a = p1 - p0;
        Point b = p2 - p0;
        Point c = p1 - p2;
        double R2 = abs(mol(c) / (xmult(a, b) / mol(a) / mol(b)));
        printf("%.2f\n", R2 * 3.141592653589793);
    }
    return 0;
}

 

posted @ 2013-01-11 20:09  金海峰  阅读(182)  评论(0编辑  收藏  举报