您的位置:首页 > 其它

向量旋转 UPC 2217

2015-04-29 20:32 211 查看
这道题目是13山东省省赛的签到题,题目大意是给等边三角形的两个定点,让求逆时针旋转之后的第三个点的坐标,原来不会向量的旋转,在网上找了找,找到一篇挺好的,直接贴过来。

向量的旋转

实际做题中我们可能会遇到很多有关及计算几何的问题,其中有一类问题就是向量的旋转问题,下面我们来具体探讨一下有关旋转的问题。



/*************************************************************************
> File Name:            upc_2217.cpp
> Author:               Howe_Young
> Mail:                 1013410795@qq.com
> Created Time:         2015年04月29日 星期三 20时03分21秒
************************************************************************/

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main()
{
int t;
double x1, y1, x2, y2;
scanf("%d", &t);
while (t--)
{
scanf("%lf %lf %lf %lf", &x1,  &y1, &x2, &y2);
double x3, y3;
x3 = (x2 - x1) * 0.5 - (y2 - y1) * sqrt(3.0) / 2.0 + x1;
y3 = (y2 - y1) * 0.5 + (x2 - x1) * sqrt(3.0) / 2.0 + y1;
printf("(%.2f,%.2f)\n", x3, y3);
}
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: