/*
Time:2019.11.2
Author: Goven
type:计算几何
err:
ref:https://blog.csdn.net/hering_linux/article/details/74510588
https://www.cnblogs.com/dengeven/p/3229136.html
注意dl,a的含义
怎样理解ref中的dl用da来表示:dl位微分,先求l关于a的表达式,l = s*tan(a),dl即对l求导
知识点:
1.atan() -- atan2() 区别:https://blog.csdn.net/chengkaizone/article/details/50558347
*/
#include<iostream>
#include<cmath>
#define PI 3.1415926
using namespace std;
double x[105], y[105];
double angle(double x0, double y0, double x1, double y1) {
double a = atan2(y0, x0);
double b = atan2(y1, x1);
if (a - b > PI) b += 2 * PI;//顶点在3,4象限,顺时针往下走
if (b - a > PI) a += 2 * PI;//顶点在3,4象限,逆时针往上走
return a - b;
}
int main()
{
double k, h, t = 0, max = 0, min = 0;
int n;
cin >> k >> h >> n;
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i];
}
x[n] = x[0], y[n] = y[0];
for (int i = 1; i <= n; i++) {
t += angle(x[i-1], y[i-1], x[i], y[i]);
if (t > max) max = t;
if (t < min) min = t;
if (max - min >= 2 * PI) {
max = min + 2 * PI;
break;
}
}
printf("%.2lf\n", k * h * (max - min));
return 0;
}
网友评论