山东省赛 Football Match

14 篇文章 0 订阅
6 篇文章 0 订阅

题目链接

Football Match

题目大意

给定一个图片的比例并且给你A和B的坐标,从而我们可以确定这面旗帜上所有关键点的坐标。如今我们将这个旗帜旋转尺度变化并位置,依然给你新的A和B的坐标,让你求出来其他点的坐标。

思路

利用极坐标的方法加上比例和角度的修正,就可以求出来所有的关键点了。
因为任何一个点到A点的距离是成比例的,且夹角恒定,实际上需要求出修正后的角度与比例修正后的长度求三角函数即可!

Code

//#include<unordered_map>
#include<algorithm>
#include<iostream>
#include<string.h>
#include <iomanip>
#include<stdio.h>
#include<vector>
#include<string>
#include<math.h>
#include<cmath>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll ll_inf = 9223372036854775807;
const int int_inf = 2147483647;
const short short_inf = 32767;
const ll less_inf = 0x3f3f3f3f;
const char char_inf = 127;
#pragma GCC optimize(2)
#define accelerate cin.tie(NULL);cout.tie(NULL);ios::sync_with_stdio(false)
#define PI 3.141592653589793
#define EPS 1.0e-8
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
inline ll read() {
	ll c = getchar(), Nig = 1, x = 0;
	while (!isdigit(c) && c != '-')c = getchar();
	if (c == '-')Nig = -1, c = getchar();
	while (isdigit(c))x = ((x << 1) + (x << 3)) + (c ^ '0'), c = getchar();
	return Nig * x;
}
inline void out(ll a) {
	if (a < 0)putchar('-'), a = -a;
	if (a > 9)out(a / 10);
	putchar(a % 10 + '0');
}
ll qpow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1)res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}
#define read read()
double dislen(double xa, double ya, double xb, double yb)
{
	return sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
}
double Cos(double a)
{
	if (a == 0)return 1;
	if (a == 90 || a == 270)return 0;
	if (a == 180)return -1;
	return cos(a * PI / 180);
}
double Sin(double a)
{
	if (a == 0 || a == 180)return 0;
	if (a == 90)return 1;
	if (a == 270)return -1;
	return sin(a * PI / 180);
}
pair<double, double>pos(double xa, double ya, double theat, double r)
{
	double x, y;
	double COS = 1;
	double SIN = 1;
	if (theat == 0)
	{
		COS = 1;
		SIN = 0;
	}
	else if (theat == 90)
	{
		COS = 0;
		SIN = 1;
	}
	else if (theat == 180)
	{
		COS = -1;
		SIN = 0;
	}
	else if (theat == 270)
	{
		COS = 0;
		SIN = -1;
	}
	else
	{
		COS = cos(theat);
		SIN = sin(theat);
	}
	x = xa + COS * r;
	y = ya + SIN * r;
	pair<double, double>res;
	res.first = x;
	res.second = y;
	return res;
}
int main()
{
	int T = read;
	while (T--)
	{
		double xa, xb, xc, xd, ya, yb, yc, yd;
		cin >> xa >> ya >> xb >> yb;
		double lenab = dislen(xa, ya, xb, yb);
		double lencd = lenab;
		double lenad = 1.5 * lenab;
		double lenbc = lenad;
		double cospian = (yb - ya) / lenab;
		double pian = acos(cospian);
		if (xb - xa > 0)
			pian = 2 * PI - pian;
		double tempx, tempy;
		tempx = lenbc * cos(pian);
		tempy = lenbc * sin(pian);
		xc = xb + tempx;
		yc = yb + tempy;
		xd = xa + tempx;
		yd = ya + tempy;
		double M = atan((10 + Sin(18) * 6) / (15 - Cos(18) * 6));
		double LenM = dislen((15 - Cos(18) * 6), (10 + Sin(18) * 6), 0, 0);
		double G = atan((10 + Sin(18) * 6) / (15 + Cos(18) * 6));
		double LenG = dislen((15 + Cos(18) * 6), (10 + Sin(18) * 6), 0, 0);
		double K = atan((10 - Cos(36) * 6) / (15 - Sin(36) * 6));
		double LenK = dislen((15 - Sin(36) * 6), (10 - Cos(36) * 6), 0, 0);
		double I = atan((10 - Cos(36) * 6) / (15 + Sin(36) * 6));
		double LenI = dislen((15 + Sin(36) * 6), (10 - Cos(36) * 6), 0, 0);
		double E = atan(16.0 / 15);
		double LenE = dislen(15, 16, 0, 0);
		double r2 = (Sin(18) / Sin(126)) * 6;
		double N = atan((10 + Sin(54) * r2) / (15 - Cos(54) * r2));
		double LenN = dislen((15 - Cos(54) * r2), (10 + Sin(54) * r2), 0, 0);
		double F = atan((10 + Sin(54) * r2) / (15 + Cos(54) * r2));
		double LenF = dislen((15 + Cos(54) * r2), (10 + Sin(54) * r2), 0, 0);
		double L = atan((10 - Sin(18) * r2) / (15 - Cos(18) * r2));
		double LenL = dislen((15 - Cos(18) * r2), (10 - Sin(18) * r2), 0, 0);
		double H = atan((10 - Sin(18) * r2) / (15 + Cos(18) * r2));
		double LenH = dislen((15 + Cos(18) * r2), (10 - Sin(18) * r2), 0, 0);
		double J = atan((10.0 - r2) / 15.0);
		double LenJ = dislen(15.0, (10.0 - r2), 0, 0);

		double Ka = lenab / 20.0;
		LenE *= Ka;
		LenF *= Ka;
		LenG *= Ka;
		LenH *= Ka;
		LenI *= Ka;
		LenJ *= Ka;
		LenK *= Ka;
		LenL *= Ka;
		LenM *= Ka;
		LenN *= Ka;
		E += pian;
		F += pian;
		G += pian;
		H += pian;
		I += pian;
		J += pian;
		K += pian;
		L += pian;
		M += pian;
		N += pian;

		pair<double, double>resE = pos(xa, ya, E, LenE);
		pair<double, double>resF = pos(xa, ya, F, LenF);
		pair<double, double>resG = pos(xa, ya, G, LenG);
		pair<double, double>resH = pos(xa, ya, H, LenH);
		pair<double, double>resI = pos(xa, ya, I, LenI);
		pair<double, double>resJ = pos(xa, ya, J, LenJ);
		pair<double, double>resK = pos(xa, ya, K, LenK);
		pair<double, double>resL = pos(xa, ya, L, LenL);
		pair<double, double>resM = pos(xa, ya, M, LenM);
		pair<double, double>resN = pos(xa, ya, N, LenN);
		printf("%.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f ", xc, yc, xd, yd, resE.first, resE.second, resF.first, resF.second, resG.first, resG.second, resH.first, resH.second);
		printf("%.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f\n", resI.first, resI.second, resJ.first, resJ.second, resK.first, resK.second, resL.first, resL.second, resM.first, resM.second, resN.first, resN.second);
	}
}

By-Round Moon

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Round moon

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值