題目:已知兩條直線,將一條直線關於另一條對稱,求它和鏡像直線的交點。
分析:計算幾何。交點一定為兩直線交點,求解即可。
說明:十一結束了╮(╯▽╰)╭。
#include <cstring>
#include <cstdio>
#include <cmath>
const double esp = 1e-6;
double dist(double x1, double y1, double x2, double y2)
{
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main()
{
double a1, b1, c1, a2, b2, c2, A, C, y, x;
while (~scanf("%lf%lf%lf%lf%lf%lf",&a1,&b1,&c1,&a2,&b2,&c2)) {
if (a1 == 0 && b1 == 0 && c1 == 0 && a2 == 0 && b2 == 0 && c2 == 0)
break;
//No fixed point exists.
if (a1*b2 == a2*b1)
printf("No fixed point exists.\n");
else {
A = b1*a2 - b2*a1;
C = c1*a2 - c2*a1;
y = C/A;
if (fabs(a1) < esp)
x = c2/a2 - b2/a2*C/A;
else x = c1/a1 - b1/a1*C/A;
printf("The fixed point is at %.2lf %.2lf\n",x,y);
}
}
return 0;
}