MATLAB: How to use the three points A1, A2, and B0 to calculate ∠A1B0A2
three points;angle
Related Solutions
The solution is definitely not unique.
Let the two result matrices be [rab11,0;0,rab22] and [rcd11;0;0;rcd22]
Set rcd22 to any non-zero non-infinite value. Then, except for possible singularities,
rab11 = rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b11+b21*d12*d11*(c11*c22-c12*c21))*a12+a11*b11*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((d12*c21*b22*a22-b12*a21*d22*c22)*b11+d12*b12*b21*(-c21*a22+a21*c22))*a12+a11*a22*b11*c22*(-d12*b22+b12*d22))*(c11*c22-c12*c21)*(d11*d22-d12*d21))
rab22 = -rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b12+b22*d12*d11*(c11*c22-c12*c21))*a22+a21*b12*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((b11*d22*c22*a11-d12*c21*a12*b21)*b12-d12*b11*b22*(c22*a11-a12*c21))*a22-a12*a21*c22*b12*(b11*d22-b21*d12))*(c11*c22-c12*c21)*(d11*d22-d12*d21))
rcd11 = -rcd22*((d11*c11*(b11*b22-b12*b21)*a22-a21*c12*b12*(b11*d21-b21*d11))*a12+a11*a22*b11*c12*(b12*d21-d11*b22))/((c21*d12*(b11*b22-b12*b21)*a22-a21*c22*b12*(b11*d22-b21*d12))*a12+a11*a22*b11*c22*(-d12*b22+b12*d22))
You can see in this that rcd22 acts as an arbitrary scale factor for the other coefficients.
The X matrix then becomes
X(1,1) = (b22*a22*rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b11+b21*d12*d11*(c11*c22-c12*c21))*a12+a11*b11*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((d12*c21*b22*a22-b12*a21*d22*c22)*b11+d12*b12*b21*(-c21*a22+a21*c22))*a12+a11*a22*b11*c22*(-d12*b22+b12*d22))*(c11*c22-c12*c21)*(d11*d22-d12*d21))-b22*a12*rab21-b21*a22*rab12-b21*a12*rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b12+b22*d12*d11*(c11*c22-c12*c21))*a22+a21*b12*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((b11*d22*c22*a11-d12*c21*a12*b21)*b12-d12*b11*b22*(c22*a11-a12*c21))*a22-a12*a21*c22*b12*(b11*d22-b21*d12))*(c11*c22-c12*c21)*(d11*d22-d12*d21)))/((a11*a22-a12*a21)*(b11*b22-b12*b21))
X(1,2) = -(b12*a22*rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b11+b21*d12*d11*(c11*c22-c12*c21))*a12+a11*b11*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((d12*c21*b22*a22-b12*a21*d22*c22)*b11+d12*b12*b21*(-c21*a22+a21*c22))*a12+a11*a22*b11*c22*(-d12*b22+b12*d22))*(c11*c22-c12*c21)*(d11*d22-d12*d21))-b12*a12*rab21-b11*a22*rab12-b11*a12*rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b12+b22*d12*d11*(c11*c22-c12*c21))*a22+a21*b12*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((b11*d22*c22*a11-d12*c21*a12*b21)*b12-d12*b11*b22*(c22*a11-a12*c21))*a22-a12*a21*c22*b12*(b11*d22-b21*d12))*(c11*c22-c12*c21)*(d11*d22-d12*d21)))/((a11*a22-a12*a21)*(b11*b22-b12*b21))
X(2,1) = -(b22*a21*rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b11+b21*d12*d11*(c11*c22-c12*c21))*a12+a11*b11*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((d12*c21*b22*a22-b12*a21*d22*c22)*b11+d12*b12*b21*(-c21*a22+a21*c22))*a12+a11*a22*b11*c22*(-d12*b22+b12*d22))*(c11*c22-c12*c21)*(d11*d22-d12*d21))-b22*a11*rab21-b21*a21*rab12-b21*a11*rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b12+b22*d12*d11*(c11*c22-c12*c21))*a22+a21*b12*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((b11*d22*c22*a11-d12*c21*a12*b21)*b12-d12*b11*b22*(c22*a11-a12*c21))*a22-a12*a21*c22*b12*(b11*d22-b21*d12))*(c11*c22-c12*c21)*(d11*d22-d12*d21)))/((a11*a22-a12*a21)*(b11*b22-b12*b21))
X(2,2) = -(b22*a21*rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b11+b21*d12*d11*(c11*c22-c12*c21))*a12+a11*b11*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((d12*c21*b22*a22-b12*a21*d22*c22)*b11+d12*b12*b21*(-c21*a22+a21*c22))*a12+a11*a22*b11*c22*(-d12*b22+b12*d22))*(c11*c22-c12*c21)*(d11*d22-d12*d21))-b22*a11*rab21-b21*a21*rab12-b21*a11*rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b12+b22*d12*d11*(c11*c22-c12*c21))*a22+a21*b12*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((b11*d22*c22*a11-d12*c21*a12*b21)*b12-d12*b11*b22*(c22*a11-a12*c21))*a22-a12*a21*c22*b12*(b11*d22-b21*d12))*(c11*c22-c12*c21)*(d11*d22-d12*d21)))/((a11*a22-a12*a21)*(b11*b22-b12*b21))
This was calculated using straight-forward linear algebra by multiplying appropriate inverses on both sides to get two isolated X equations, and then solve()'ing for the corresponding components to be the same.
clc; clear all ;x=[0 0.025 0.05 0.075 0.1 0.125 0.15 0.175 0.2 0.225 0.25 0.275 0.3 0.325 0.35 0.375 0.4 0.425 0.45 0.475 0.5 0.525 0.55 0.575 0.6 0.625 0.65 0.675 0.7 0.725 0.75 0.775 0.8 0.825 0.85 0.875 0.9 0.925 0.95 0.975 1 ] ;y=[1.422 1.427 1.431 1.396 1.396 1.377 1.377 1.358 1.357 1.338 1.338 1.319 1.318 1.301 1.301 1.288 1.287 1.278 1.278 1.274 1.274 1.275 1.276 1.282 1.282 1.294 1.294 1.309 1.310 1.328 1.328 1.348 1.348 1.367 1.367 1.386 1.386 1.413 1.413 1.039 1.025] ;yi = smooth(y) ;plot(x,y,'r')hold onplot(x,yi,'b') ;
Best Answer