I am trying to understand a C code that moves the mesh nodes for each time step and i am totally struck on the parameters t1 and t2 please help me sorting this out. So here is what the function gets (Xa,Ya) (Xb,Yb) (Xc,Yc) and (Xd,Yd) where (Xc,Yc) is the origin (0,0) about which mesh rotates now i have a function that calculates t1 and t2 and (i think t1 is the parameter in barycentre form of line that gives intersection point between two line formed by (Xa,Ya)(Xb,Yb) and (Xc,Yc)(Xd,Yd)) and i have no idea what t2 is...
The code is
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;
}
and the value returned is used to update the mesh point if the following condition is satisfied
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;
}
please can some recognize what t2 is and correct me if my thought about t1 is wrong,The point(*x,*y) i get is the intersection point between two lines
A + t1 * (B - A) = C + t2 * (D - C)
- but I haven't yet worked out the math to confirm whether this interpretation is correct. \$\endgroup\$