三个摄像头,在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. Android设计模式(三)--装饰模式

    1.定义: Attach additional responsibilities to an object dynamically keeping the same interface.  Decoa ...

  2. bash脚本编程知识储备

    bash脚本编程:     脚本程序:解释器解释执行: 首先得理清一些琐碎的知识点,我尽量把我所学的帮朋友一起梳理一下 编程环境:(我会在接下来的篇章,图文例子三结合的方式带大家一起学习)       ...

  3. logstash tcp multihost output(多目标主机输出,保证TCP输出链路的稳定性)

    在清洗日志时,有一个应用场景,就是TCP输出时,须要在一个主机挂了的情况下,自已切换到下一个可用入口.而原tcp output仅支持单个目标主机设定.故本人在原tcp的基础上,开发出tcp_multi ...

  4. iOS 相似QQ空间表视图下拉头部视图放大效果实现

    UITableView 是 UIScrollView 的子类. 所以 UIScrollView 的代理方法.在UITableView 上相同可以得到适用. 既然如此那么我们就行知道.在表格下拉的过程中 ...

  5. DOM基础----DOM(一)

    DOM(Document Object Model),中文名称为文档对象模型.是处理可扩展标识语言的标准编程接口,主要针对HTML和XML.DOM描绘了一个层次化的节点树,开发者能够加入.改动和移除页 ...

  6. 2015.04.21,外语,读书笔记-《Word Power Made Easy》 11 “如何辱骂敌人” SESSION 31

    1.no reverence iconoclast([ai'kɔnәklæst]  n. 毁坏宗教神像的人, 提倡打破旧习的人)藐视传统.在青年的反叛期很容易出现iconoclasm([ai'kɔnә ...

  7. mysqli简介

    mysqli简介 PHP MySQLi 简介 PHP MySQLi = PHP MySQL Improved! MySQLi 函数允许您访问 MySQL 数据库服务器. 注释:MySQLi 扩展被设计 ...

  8. 高斯混合模型Gaussian Mixture Model (GMM)——通过增加 Model 的个数,我们可以任意地逼近任何连续的概率密分布

    从几何上讲,单高斯分布模型在二维空间应该近似于椭圆,在三维空间上近似于椭球.遗憾的是在很多分类问题中,属于同一类别的样本点并不满足“椭圆”分布的特性.这就引入了高斯混合模型.——可以认为是基本假设! ...

  9. PySide2运行出错问题解决

    PySide2是QT官方出的Python的QT封装, 不过默认安装运行时候会有一些小问题, 可能是系统里已经安装过其他版本QT的原因, 会报错如下: PySide2 qt.qpa.plugin: Co ...

  10. 18.QT消息链筛选机制以及组合键

    mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> 5 #include <Q ...