您的位置:首页 > 产品设计 > UI/UE

第四届山东省赛A题 Rescue The Princess

2018-03-11 14:05 239 查看
三角定位法:已知两点和角度,求以这两点为向量转过逆时针转过给定角度后的新点坐标.

以给定向量和与其逆时针垂直的向量建立基向量,根据角度分解求解之

#include<cstdio>
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
int T;
cin >> T;
while(T--)
{
double x1,y1,x2,y2,x3,y3;
cin >> x1 >> y1 >> x2 >> y2;
double tmp1 = x2 - x1;
double tmp2 = y2 - y1;
x3=tmp1 / 2 - tmp2 * sqrt(3) / 2 ;
y3=tmp2 / 2 + tmp1 * sqrt(3) / 2 ;
cout << '(' << fixed << setprecision(2) << x3 << ',' << y3 << ')' << endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐