描述

The Archeologists of the Current Millenium (ACM) now and then discover ancient artifacts located at vertices of regular polygons. The moving sand dunes of the desert render the excavations difficult and thus once three vertices of a polygon are discovered there is a need to cover the entire polygon with protective fabric.

输入

Input contains multiple cases. Each case describes one polygon. It starts with an integer n <= 50, the number of vertices in the polygon, followed by three pairs of real numbers giving the x and y coordinates of three vertices of the polygon. The numbers are separated by whitespace. The input ends with a n equal 0, this case should not be processed.

输出

For each line of input, output one line in the format shown below, giving the smallest area of a rectangle which can cover all the vertices of the polygon and whose sides are parallel to the x and y axes.

样例输入

4
10.00000 0.00000
0.00000 -10.00000
-10.00000 0.00000
6
22.23086 0.42320
-4.87328 11.92822
1.76914 27.57680
23
156.71567 -13.63236
139.03195 -22.04236
137.96925 -11.70517
0

样例输出

Polygon 1: 400.000
Polygon 2: 1056.172
Polygon 3: 397.673

题意

已知正n边形三点求最小矩形覆盖面积

题解

正n边形上三点,求出正n边形上唯一外接圆

顺时针绕圆心旋转圆心角得到每个顶点的坐标

然后答案就是(最大的x-最小的x)*(最大的y-最小的y)

代码

 #include<bits/stdc++.h>
using namespace std; struct Point
{
double x,y;
Point(double x=,double y=):x(x),y(y){}
};
Point tcircle(Point pt1,Point pt2,Point pt3,double &radius)
{
double x1=pt1.x,x2=pt2.x,x3=pt3.x;
double y1=pt1.y,y2 =pt2.y,y3=pt3.y;
double a=x1-x2,b=y1-y2,c=x1-x3,d=y1-y3;
double e=((x1*x1-x2*x2)+(y1*y1-y2*y2))/2.0;
double f=((x1*x1-x3*x3)+(y1*y1-y3*y3))/2.0;
double det=b*c-a*d;
double x0=(b*f-d*e)/det;
double y0=(c*e-a*f)/det;
radius=hypot(x1-x0,y1-y0);
return Point(x0,y0);
}
Point rotateShun(Point p,Point dx,double selt)
{
double xx=(p.x-dx.x)*cos(-selt)-(p.y-dx.y)*sin(-selt)+dx.x;
double yy=(p.x-dx.x)*sin(-selt)+(p.y-dx.y)*cos(-selt)+dx.y;
return Point(xx,yy);
}
Point p[];
int main()
{
int n,ca=;
double PI=acos(-);
while(scanf("%d",&n),n)
{
for(int i=;i<=;i++)
scanf("%lf%lf",&p[i].x,&p[i].y);
double r=.;
Point cir=tcircle(p[],p[],p[],r);
double selt=.*PI/n;
double maxx=p[].x,minx=p[].x,maxy=p[].y,miny=p[].y;
for(int i=;i<=n;i++)
{
p[i]=rotateShun(p[i-],cir,selt);
maxx=max(maxx,p[i].x);
minx=min(minx,p[i].x);
maxy=max(maxy,p[i].y);
miny=min(miny,p[i].y);
}
double ans=(maxx-minx)*(maxy-miny);
printf("Polygon %d: %.3f\n",ca++,ans);
}
return ;
}

TZOJ 2392 Bounding box(正n边形三点求最小矩形覆盖面积)的更多相关文章

  1. 论文阅读笔记四十七:Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression(CVPR2019)

    论文原址:https://arxiv.org/pdf/1902.09630.pdf github:https://github.com/generalized-iou 摘要 在目标检测的评测体系中,I ...

  2. 3D空间中的AABB(轴向平行包围盒, Aixe align bounding box)的求法

    引言 在前面的一篇文章中讲述了怎样通过模型的顶点来求的模型的包围球,而且还讲述了基本包围体除了包围球之外,还有AABB包围盒.在这一章,将讲述怎样依据模型的坐标求得它的AABB盒. 表示方法 AABB ...

  3. Latex 中插入图片no bounding box 解决方案

    在windows下,用latex插入格式为jpg,png等图片会出现no bounding box 的编译错误,此时有两个解决办法: 1.将图片转换为eps格式的图片 \usepackage{grap ...

  4. bounding box的简单理解

    1. 小吐槽 OverFeat是我看的第一篇深度学习目标检测paper,因为它是第一次用深度学习来做定位.目标检测问题.可是,很难懂...那个bounding box写得也太简单了吧.虽然,很努力地想 ...

  5. 第二十六节,滑动窗口和 Bounding Box 预测

    上节,我们学习了如何通过卷积网络实现滑动窗口对象检测算法,但效率很低.这节我们讲讲如何在卷积层上应用这个算法. 为了构建滑动窗口的卷积应用,首先要知道如何把神经网络的全连接层转化成卷积层.我们先讲解这 ...

  6. maya cmds pymel polyEvaluate 获取 bounding box

    maya cmds pymel polyEvaluate 获取 bounding box cmds.polyEvaluate(bc = 1)   #模型 cmds.polyEvaluate(bc2 = ...

  7. Torch 两个矩形框重叠面积的计算 (IoU between tow bounding box)

    Torch 两个矩形框重叠面积的计算 (IoU between tow bounding box) function DecideOberlap(BBox_x1, BBox_y1, BBox_x2, ...

  8. elasticsearch Geo Bounding Box Query

    Geo Bounding Box Query 一种查询,允许根据一个点位置过滤命中,使用一个边界框.假设以下索引文档: PUT /my_locations { "mappings" ...

  9. 两个Bounding Box的IOU计算代码

    Bounding Box的数据结构为(xmin,ymin,xmax,ymax) 输入:box1,box2 输出:IOU值 import numpy as np def iou(box1,box2): ...

随机推荐

  1. 基于STM8的ADC读取---STM8-第四章

    1. 综诉 想学会如何在STM8上使用ADC这个功能,我们先得了解单片机中ADC究竟是什么. ADC是模拟信号转成数值信号,单片机只能识别TTL电平,其实就是 1 或者 0 ,但是如果我们给它一个3. ...

  2. SQL Server 2008 R2中配置作业失败后邮件发送通知

    SQL Server日常维护中难免会遇到作业失败的情况.失败后自然需要知道它失败了,除了例行检查可以发现出错以外,有一个较实时的监控还是很有必要的.比较专业的监控系统比如SCOM虽然可以监控作业执行情 ...

  3. Vue 路由的模块化

    其实就是对路由配置和实例化的过程进行js封装,挂载路由的时候依然在main.js中: 步骤: 1.在src文件夹下新建一个router文件夹,在router文件夹下新建文件router.js; 2.引 ...

  4. RAMDISK 内存盘工具推荐

    好了直接推荐, 1.魔方内存盘  使用方便 ,但是关机后消失.绿色 2.Primo Ramdisk Ultimate Edition5.5 3.GiliSoft RAMDisk 4.QSoft RAM ...

  5. Vue 封装可向左向右查看图片列表的组件

    <template> <div class="content-container"> <div class="content-contain ...

  6. 团队项目需求分析——NABCD

    N(Need)需求 经发现,很多人在理发时都要经过漫长的排队等待时间,这些时间也就因此白白浪费掉了,而且一些理发店也会因个别顾客不愿等待而损失客源.对此,我们设计出了这款小软件——理了么,一款专门为理 ...

  7. IntelliJ IDEA 破解Jrebel6.3.0安装

    首先下载所必要的两个文件(jrebel3.6.0和cracked文件) 密码:pvsd 注意:如果不是该版本的Jrebel该破解文件可能无效. 步骤1:安装 解压文件得出两个压缩包 在idea中选择 ...

  8. POJ_1321

    题目   在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别.要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆 ...

  9. linux命令--cut的使用

    cut 是一个选取命令,将一段数据进行分析,取得我们想要的 语法: cut (参数)(文件) 常用参数: -b:仅显示行中指定直接范围的内容:(以字节为单位分割) -c:仅显示行中指定范围的字符:(以 ...

  10. springboot问题总结

    前端使用jsp界面,但是jsp界面中引用的静态资源无论如何也加载不出来,弄一天了,哎 最后把pom文件里的jar全干掉,代码移除,就剩下登录界面,看css能不能进来,结果没问题, 然后看类里面的注解, ...