三个摄像头,在XOY上与立体的点求出在平面上的交点,然后求出凸包。三个凸包相交的面积即是所求,即是可以用半平面交的方法求解了。

模板题了。代码拿别人的。

#include<cmath>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int mm=111;
typedef double DIY;
struct point
{
DIY x,y;
point() {}
point(DIY _x,DIY _y):x(_x),y(_y) {}
} g[mm];
point MakeVector(point &P,point &Q)
{
return point(Q.x-P.x,Q.y-P.y);
}
DIY CrossProduct(point P,point Q)
{
return P.x*Q.y-P.y*Q.x;
}
DIY MultiCross(point P,point Q,point R)
{
return CrossProduct(MakeVector(Q,P),MakeVector(Q,R));
}
struct halfPlane
{
point s,t;
double angle;
halfPlane() {}
halfPlane(point _s,point _t):s(_s),t(_t) {}
halfPlane(DIY sx,DIY sy,DIY tx,DIY ty):s(sx,sy),t(tx,ty) {}
void GetAngle()
{
angle=atan2(t.y-s.y,t.x-s.x);
}
} hp[mm<<2],q[mm<<2];
point IntersectPoint(halfPlane P,halfPlane Q)
{
DIY a1=CrossProduct(MakeVector(P.s,Q.t),MakeVector(P.s,Q.s));
DIY a2=CrossProduct(MakeVector(P.t,Q.s),MakeVector(P.t,Q.t));
return point((P.s.x*a2+P.t.x*a1)/(a2+a1),(P.s.y*a2+P.t.y*a1)/(a2+a1));
}
bool cmp1(halfPlane P,halfPlane Q)
{
if(fabs(P.angle-Q.angle)<1e-8)
return MultiCross(P.s,P.t,Q.s)>0;
return P.angle<Q.angle;
}
bool IsParallel(halfPlane P,halfPlane Q)
{
return fabs(CrossProduct(MakeVector(P.s,P.t),MakeVector(Q.s,Q.t)))<1e-8;
}
void HalfPlaneIntersect(int n,int &m)
{
sort(hp,hp+n,cmp1);
int i,l=0,r=1;
for(m=i=1; i<n; ++i)
if(hp[i].angle-hp[i-1].angle>1e-8)hp[m++]=hp[i];
n=m;
m=0;
q[0]=hp[0],q[1]=hp[1];
for(i=2; i<n; ++i)
{
if(IsParallel(q[r],q[r-1])||IsParallel(q[l],q[l+1]))return;
while(l<r&&MultiCross(hp[i].s,hp[i].t,IntersectPoint(q[r],q[r-1]))>0)--r;
while(l<r&&MultiCross(hp[i].s,hp[i].t,IntersectPoint(q[l],q[l+1]))>0)++l;
q[++r]=hp[i];
}
while(l<r&&MultiCross(q[l].s,q[l].t,IntersectPoint(q[r],q[r-1]))>0)--r;
while(l<r&&MultiCross(q[r].s,q[r].t,IntersectPoint(q[l],q[l+1]))>0)++l;
q[++r]=q[l];
for(i=l; i<r; ++i)
g[m++]=IntersectPoint(q[i],q[i+1]);
}
point data[3][mm],stack[mm],MinA;
int top;
DIY Direction(point pi,point pj,point pk) //判断向量PiPj在向量PiPk的顺逆时针方向 +顺-逆0共线
{
return (pj.x-pi.x)*(pk.y-pi.y)-(pk.x-pi.x)*(pj.y-pi.y);
}
DIY Dis(point a,point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
bool cmp(point a,point b)
{
DIY k=Direction(MinA,a,b);
if(k>0) return 1;
if(k<0) return 0;
return Dis(MinA,a)>Dis(MinA,b);
}
void Graham_Scan(point *a,int numa)
{
for(int i=0; i<numa; i++)
if(a[i].y<a[0].y||(a[i].y==a[0].y&&a[i].x<a[0].x))
swap(a[i],a[0]);
MinA=a[0],top=0;
sort(a+1,a+numa,cmp);
stack[top++]=a[0],stack[top++]=a[1],stack[top++]=a[2];
for(int i=3; i<numa; i++)
{
while(Direction(stack[top-2],stack[top-1],a[i])<0&&top>=2)
top--;
stack[top++]=a[i];
}
}
int main()
{
int n;
double x[mm],y[mm],z[mm],lix[3],liy[3];
while(~scanf("%d",&n))
{
int numd=0;
for(int i=0; i<n; i++)
scanf("%lf%lf%lf",&x[i],&y[i],&z[i]);
for(int i=0; i<3; i++)
scanf("%lf%lf",&lix[i],&liy[i]);
for(int j=0; j<3; j++)
for(int i=0; i<n; i++)
data[j][i].x=(-100)/(z[i]-100)*(x[i]-lix[j])+lix[j],
data[j][i].y=(-100)/(z[i]-100)*(y[i]-liy[j])+liy[j];
int numm=0;
for(int j=0; j<3; j++)
{
Graham_Scan(data[j],n);
for(int i=0; i<top; i++)
{
hp[numm]=halfPlane(stack[i],stack[(i+1)%top]);
hp[numm].GetAngle();
numm++;
}
}
int m;
double s1=0;
point o(0,0);
HalfPlaneIntersect(numm,m);
for(int i=0; i<m; i++)
s1+=Direction(o,g[i],g[(i+1)%m]);
s1=fabs(s1)/2;
printf("%.2f\n",s1);
}
return 0;
}

  

HDU 4316 Contest 2的更多相关文章

  1. HDU 5045 Contest(状压DP)

    Problem Description In the ACM International Collegiate Programming Contest, each team consist of th ...

  2. hdu - 5045 - Contest(国家压缩dp)

    意甲冠军:N个人M通过主打歌有自己的期望,每个问题发送人玩.它不能超过随机播放的次数1,追求最大业绩预期 (1 ≤ N ≤ 10,1 ≤ M ≤ 1000). 主题链接:pid=5045" ...

  3. [ACM] hdu 5045 Contest (减少国家Dp)

    Contest Problem Description In the ACM International Collegiate Programming Contest, each team consi ...

  4. HDU–5988-Coding Contest(最小费用最大流变形)

    Coding Contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  5. hdu 5045 Contest(状态压缩DP)

    题解:我们使用一个二位数组dp[i][j]记录进行到第i个任务时,人组合为j时的最大和(这里的j我们用二进制的每位相应一个人). 详细见代码: #include <iostream> #i ...

  6. HDU 5045 Contest

    pid=5045">主题链接~~> 做题感悟:比赛时这题后来才写的,有点小尴尬.两个人商议着写写了非常久才写出来,I want to Powerful ,I believe me ...

  7. HDU 4335 Contest 4

    利用降幂公式..呃,还是自己去搜题解吧.知道降幂公式后,就不难了. #include <iostream> #include <cstdio> #include <alg ...

  8. HDU 4339 Contest 4

    树状数组,主要是抓住要求连续1的个数.这样,初始时,相同的加1,不同的加0. 查询时,用二分搜索右边界.就是比较当前mid-l+1的值与他们之间1的个数(这可以通过树状数组求区间和得出),记录右边界即 ...

  9. HDU 4334 Contest 4

    本来以为是一道水题,好吧,做了才知道,出题的人有多牛.二分搜索是不可能的了,因为会超内存... 看到别人的搜索两个集合的提示,我就自己一边去想了.终于想出来了: 可以这样做,先把每两个集合的和值枚举出 ...

随机推荐

  1. Python模块路径查找

    本文主要介绍如何查找某个Python模块的绝对路径,下面以opencv模块的查找为例.有两种方法 第一种方法 打开一个终端,输入 python -v import cv2 最后一行显示如下 第二种方法 ...

  2. [Tailwind] Apply mobile-first Responsive Classes in Tailwind

    In this lesson, we take a look at tailwind's mobile-first CSS architecture and learn how to apply st ...

  3. 安装ftp碰到的问题及解决方法

    1   CRT显示乱码:     本地windows机器.改动SecureCRT的设置.找到"选项"->"会话选项"->"外观" ...

  4. poj 2683 Ohgas&#39; Fortune 利率计算

    水题. 代码: //poj 2683 //sep9 #include <iostream> using namespace std; int main() { int cases; sca ...

  5. FetchType与FetchMode的差别

    使用例: @OneToMany(mappedBy="item",cascade=CascadeType.ALL,fetch=FetchType.EAGER) @Fetch(valu ...

  6. ”危险“的RESTRICT与GCC的编译优化(编程者对编译器所做的一个“承诺”:使用restrict修饰过的指针,它所指向的内容只能经由该指针修改)

    restrict是C99标准中新添加的关键字,对于从C89标准开始起步学习C语言的同学来说(包括我),第一次看到restrict还是相当陌生的.Wikipedia给出的解释如下: In the C p ...

  7. 【NOI 2002】 银河英雄传说

    [题目链接] https://www.luogu.org/problemnew/show/P1196 [算法] 并查集 [代码] #include<bits/stdc++.h> using ...

  8. Java-SpringCloud:目录

    ylbtech-Java-SpringCloud:目录 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部     6.返回顶部   作者:ylbtech出处:htt ...

  9. DBS-Oracle:表的连接查询

    ylbtech-DBS-Oracle:表的连接查询 链接查询是指基于两个或两个以上表或试图的查询.在实际应用中,查询单个表可能无法满足应用程序的实际需求(例如显示雇员的部门名称以及雇员名),在这种情况 ...

  10. Qt-窗口部件概念介绍

    前言:包括基础窗口部件QWidget.对话框QDialog.QFrame类族 .按钮部件.行编辑器.数值设定框以及滑块部件. 一.基础窗口部件QWidget 窗口部件(Widget)是Qt中建立用户界 ...