hdu4998 Rotate【计算几何】

本文介绍了一个有趣的旋转合成问题,即如何通过多次不同中心点的旋转,找到等效于这些旋转的单一旋转中心点及其旋转角度。文章提供了详细的解决思路与算法实现,并附带了完整的C++代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Noting is more interesting than rotation! 

Your little sister likes to rotate things. To put it easier to analyze, your sister makes n rotations. In the i-th time, she makes everything in the plane rotate counter-clockwisely around a point ai by a radian of pi. 

Now she promises that the total effect of her rotations is a single rotation around a point A by radian P (this means the sum of pi is not a multiplier of 2π). 

Of course, you should be able to figure out what is A and P :). 
Input
The first line contains an integer T, denoting the number of the test cases. 

For each test case, the first line contains an integer n denoting the number of the rotations. Then n lines follows, each containing 3 real numbers x, y and p, which means rotating around point (x, y) counter-clockwisely by a radian of p. 

We promise that the sum of all p's is differed at least 0.1 from the nearest multiplier of 2π. 

T<=100. 1<=n<=10. 0<=x, y<=100. 0<=p<=2π.
Output
For each test case, print 3 real numbers x, y, p, indicating that the overall rotation is around (x, y) counter-clockwisely by a radian of p. Note that you should print p where 0<=p<2π. 

Your answer will be considered correct if and only if for x, y and p, the absolute error is no larger than 1e-5. 
Sample Input
1
3
0 0 1
1 1 1
2 2 1
Sample Output
1.8088715944 0.1911284056 3.0000000000

划重点!

一个点绕定点旋转的坐标公式:


在平面坐标上,任意点P(x1,y1),绕一个坐标点Q(x2,y2)旋转θ角度后,新的坐标设为(x, y)的计算公式:
[cpp]  view plain  copy
  1. x= (x1 - x2)*cos(θ) - (y1 - y2)*sin(θ) + x2 ;  
  2. y= (x1 - x2)*sin(θ) + (y1 - y2)*cos(θ) + y2 ;  

这道题里最后的旋转角度就是前面所有的旋转角度加起来 因为不管绕哪一个点旋转 整个画面都转过了相同的角度 画面上的每一个点也都转过了相同的角度

先设一个点 对于每一次旋转都对这个点进行旋转 就可以得到最后的时候这个点的坐标

在根据这个点最后的坐标与最开始的坐标 可以反推出旋转中心

emmm感觉自己高中学的几何的公式都忘光了 计算能力也大大下降 解一个复杂一点的方程都解不出了啊天哪好难过


#include <iostream>
#include <algorithm>
#include <cstring>

#include <cstdio>

#include <cmath>

using namespace std;
#define PI 3.1415926
#define EPS 1.0e-5

int t, n;
struct point{
    double x, y;
}p[15];

point rot(point& p, point& ding, double theta)
{
    point c;
    c.x = (p.x - ding.x) * cos(theta) - (p.y - ding.y) * sin(theta) + ding.x;
    c.y = (p.x - ding.x) * sin(theta) + (p.y - ding.y) * cos(theta) + ding.y;
    return c;
}

int main()
{
    cin>>t;
    while(t--){
        scanf("%d",&n);
        double anangle = 0.0;
        point a, b;
        a.x = -1.0; a.y = -20.0;
        b.x = -1.0; b.y = -20.0;
        for(int i = 0; i < n; i++){
            double angle;
            scanf("%lf%lf%lf",&p[i].x, &p[i].y, &angle);
            a = rot(a, p[i], angle);
            anangle += angle;
            while(anangle >= 2 * PI){
                anangle -= 2 * PI;
            }

        }

        point ans;
        ans.y =(a.x*sin(anangle)+a.y*(1-cos(anangle))-(b.x*cos(anangle)-b.y*sin(anangle))*sin(anangle)-(b.x*sin(anangle)+b.y*cos(anangle))*(1-cos(anangle)))/(2-2*cos(anangle));
        ans.x=(a.x*(1-cos(anangle))-a.y*sin(anangle)-(b.x*cos(anangle)-b.y*sin(anangle))*(1-cos(anangle))+(b.x*sin(anangle)+b.y*cos(anangle))*sin(anangle))/(2-2*cos(anangle));
        printf("%.6f %.6f %.6f\n", ans.x, ans.y, anangle);
    }
    return 0;

}


内容概要:该研究通过在黑龙江省某示范村进行24小时实地测试,比较了燃煤炉具与自动/手动进料生物质炉具的污染物排放特征。结果显示,生物质炉具相比燃煤炉具显著降低了PM2.5、CO和SO2的排放(自动进料分别降低41.2%、54.3%、40.0%;手动进料降低35.3%、22.1%、20.0%),但NOx排放未降低甚至有所增加。研究还发现,经济性和便利性是影响生物质炉具推广的重要因素。该研究不仅提供了实际排放数据支持,还通过Python代码详细复现了排放特征比较、减排效果计算和结果可视化,进一步探讨了燃料性质、动态排放特征、碳平衡计算以及政策建议。 适合人群:从事环境科学研究的学者、政府环保部门工作人员、能源政策制定者、关注农村能源转型的社会人士。 使用场景及目标:①评估生物质炉具在农村地区的推广潜力;②为政策制定者提供科学依据,优化补贴政策;③帮助研究人员深入了解生物质炉具的排放特征和技术改进方向;④为企业研发更高效的生物质炉具提供参考。 其他说明:该研究通过大量数据分析和模拟,揭示了生物质炉具在实际应用中的优点和挑战,特别是NOx排放增加的问题。研究还提出了多项具体的技术改进方向和政策建议,如优化进料方式、提高热效率、建设本地颗粒厂等,为生物质炉具的广泛推广提供了可行路径。此外,研究还开发了一个智能政策建议生成系统,可以根据不同地区的特征定制化生成政策建议,为农村能源转型提供了有力支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值