线交叉码中的参数说明

我想了解一个移动网格节点的C代码,每个时间步骤,我完全触及参数t1和t2,请帮我分拣出来。 所以这里是函数得到的(Xa,Ya)(Xb,Yb)(Xc,Yc)和(Xd,Yd)其中(Xc,Yc)是网格旋转的原点(0,0),现在我有(Xa,Ya)(Xb,Yb)和(Xc,Yc)(Xd,Yd)形成的两条线之间的交点的线的重心forms中的参数)我不知道t2是什么

代码是

static void find_t(real xa, real ya, real xb, real yb, real xc, real yc, real xd, real yd, real *t1, real *t2, int * flag) { if((xd==xc)&&(xb!=xa)) { if(yd==yc) { Message0("\nc and d are the same points-aborting!!!\n"); exit(0); } (*flag) = 2; (*t1) = (xc-xa)/(xb-xa); (*t2) = ((yb-ya)*(*t1)-(yc-ya))/(yd-yc); } else if((xd!=xc)&&(xb==xa)) { if(yb==ya) { Message0("\na and b are the same points-aborting!!!\n"); exit(0); } (*flag) = 2; (*t2) = (xc-xa)/(xc-xd); (*t1) = ((yd-yc)*(*t2)+(yc-ya))/(yb-ya); } else if((xd==xc)&&(xb==xa)) { (*flag) = 0; return; } else { real k1, k2; k1 = (yd-yc)/(xd-xc); k2 = (yb-ya)/(xb-xa); if(fabs(k2)>=fabs(k1)) { if(k1==k2) { (*flag) = 0; return; } (*flag) = 1; (*t1) = (-k1*(xc-xa)+(yc-ya))/((yb-ya)-k1*(xb-xa)); (*t2) = ((xb-xa)*(*t1)-(xc-xa))/(xd-xc); } else { (*flag) = 1; (*t2) = (-k2*(xc-xa)+(yc-ya))/(-(yd-yc)+k2*(xd-xc)); (*t1) = ((xd-xc)*(*t2)+(xc-xa))/(xb-xa); } } return; } 

如果满足以下条件,则返回的值用于更新网格点

  if(((flag==1)||(flag==2))&&(t1<=1+cal_small_number(j))&&(t1>=-cal_small_number(j))&&(t2>=0)) { (*x) = (1-t1)*pt1[0] + t1*pt2[0]; (*y) = (1-t1)*pt1[1] + t1*pt2[1]; return; } 

如果我对t1的想法是错误的,请能够认识到t2是什么,纠正我,得到的点(* x,* y)是两行之间的交点