hoj1700
利用点积和叉积列方程
(x0,y0)X (x1,y1) = sin(120)*R^2 (r为圆的半径)
(x0,y0) * (x1,y1) = cos(120)*R^2
结果为:
x1=b*x0-a*y0;
a=sin120;
y1=b*y0+a*x0;
b=cos120;
View Code
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define eps 0.0005
void make(double x0, double y0, double &x1, double &y1)
{
double a, b;
a = sqrt(3.0) / 2.0;
b = -1 / 2.0;
x1 = x0 * b - y0 * a;
y1 = y0 * b + x0 * a;
}
int main()
{
//freopen("D:\\t.txt", "r", stdin);
int t;
scanf("%d", &t);
while (t--)
{
double x0, y0, x1, y1, x2, y2;
scanf("%lf%lf", &x0, &y0);
make(x0, y0, x1, y1);
make(x1, y1, x2, y2);
if (y1 < y2 || abs(y1 - y2) < eps && x1 - x2 < eps)
{
swap(y1, y2);
swap(x1, x2);
}
printf("%.3f %.3f %.3f %.3f\n", x2, y2, x1, y1);
}
return 0;
}