标签:des style color io os ar for sp div
1 0.000 0.000 4.000 0.000 1.000 1.000 3.000 1.000
2.000 0.000
#include <stdio.h> void jd(double a1,double b1,double c1,double a2,double b2,double c2,double &x,double &y)//两直线交点 { x=(b2*c1-b1*c2)/(a1*b2-a2*b1); y=(a2*c1-a1*c2)/(a2*b1-a1*b2); } void line(double x1,double y1,double x2,double y2,double &a,double &b,double &c)//两点确定的直线 { a=y1-y2; b=x2-x1; c=x2*y1-x1*y2; } int main() { int T; double x1,x2,y1,y2,x0,y0,x3,y3,a1,a2,b1,b2,c1,c2,x,y; scanf("%d",&T); while(T--) { scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x0,&y0,&x3,&y3); a1=x1-x2;//过(x0,y0)垂直与镜子的直线 b1=y1-y2; c1=x0*x1-x0*x2+y0*y1-y0*y2; line(x1,y1,x2,y2,a2,b2,c2);//镜子所在直线 jd(a1,b1,c1,a2,b2,c2,x,y);//(x,y)上面两条直线的交点 x+=x-x0; y+=y-y0; line(x,y,x3,y3,a1,b1,c1); jd(a1,b1,c1,a2,b2,c2,x,y); printf("%.3f %.3f\n",x,y); } }
HDU-2857-Mirror and Light(计算几何)
标签:des style color io os ar for sp div
原文地址:http://blog.csdn.net/faithdmc/article/details/39748723