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

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/AC_jie/article/details/79515934

三角定位法:已知两点和角度,求以这两点为向量转过逆时针转过给定角度后的新点坐标.
以给定向量和与其逆时针垂直的向量建立基向量,根据角度分解求解之

#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;
}

猜你喜欢

转载自blog.csdn.net/AC_jie/article/details/79515934
今日推荐