计算平行平面上与法线向量的距离

时间:2020-04-30 21:09:23

标签: matlab multidimensional-array distance rotational-matrices matrix-transform

我的数学(和matlab)还不满足于此,所以我谦虚地寻求您的帮助:

我有一个通过环流的模型。我想得到峰值流点的半径和到中心线的环的半径。

因此,在3D模型中,我有3个点,即ABC,我们知道其坐标,但未与xyz对齐。我希望AB是平面上的两个点,而点A是原点(环面的中心)。点C在平行于上一个平面(峰值流动点)的平面上。我想知道如何计算C平面上的C与穿过A点的AB平面的法向矢量之间的距离。

这是模型的照片: Flow through an annulus Points in the model

现在,我有一个比我想出一个Matlab代码更聪明的朋友来翻译和旋转模型,然后计算AB和AnormC的大小。但是,它无法正常工作,因为它使C的半径大于B的半径。我也意识到,有多种方法可以解决此问题。

代码在下面。有什么想法我们错了吗?也许有更好的方法可以做到这一点?我想到了向量,但是我的涂鸦却几乎没有。

谢谢。

托比

%Origin
O = [0 0 0]';           Ox = [O' 1]';
%Vector co-ordinates of 1 (A - Origin centreline), ...
% 2 (B - Radius of artery), and 3 (C - Radius of Peak Velocity)
A = [13.3856 -60.0377 15.8443]';           Ax = [A' 1]';
B = [26.9486 -51.0653 20.9265]';           Bx = [B' 1]';
C = [16.2240 -92.5594 40.8687]';           Cx = [C' 1]';
%Find the new i unit vector in the old co-ords (the unit vector along the new x axis)
AB = B - A;
magAB = sqrt(sum(AB.^2));
new_i=AB./magAB;
%Calculate the angle to rotate through Z when transforming
thetaZ = atan(new_i(2)/new_i(1));
%Hence, define the translation matrix (to move the origin to A) and ...
% the rotation matrixes (to align the new x axis with AB and new_i)
T = [1 0 0 -A(1) ; 0 1 0  -A(2) ; 0 0 1 -A(3) ; 0 0 0 1];
Rz = [cos(thetaZ) sin(thetaZ) 0 0 ; -sin(thetaZ) cos(thetaZ) 0 0 ; 0 0 1 0 ; 0 0 0 1];
Transform = Rz * T;
%transform Cx to the new co-ordinates by translation and rotation in Z
A_dash = round(Transform * Ax,10);
B_dash = round(Transform * Bx,10);
C_dash = round(Transform * Cx,10);
new_i_t = round(Transform * [new_i' 1]',4); new_i_t = new_i_t(1:3);
new_O = round(Transform * Ox,4); new_O = new_O(1:3);
A_dash = A_dash(1:3); B_dash = B_dash(1:3); C_dash = C_dash(1:3);
%Perform a final rotation in Y
thetaY = atan(B_dash(3)/B_dash(1));
Ry = [cos(thetaY) 0 sin(thetaY) ; 0 1 0 ; -sin(thetaY) 0 cos(thetaY)];
B_dash = Ry * B_dash;
C_dash = Ry * C_dash;
%Taking point C onto the plane of AB
C_dashflat = C_dash.*[1 1 0]';
%Find Radius of Peak Flow 
Radius_Peak_Flow = sqrt(sum(C_dashflat.^2));
%Find Radius of Artery  
Radius_Artery = magAB;
%Ratio (between 0 -1)
Ratio = Radius_Peak_Flow/Radius_Artery

0 个答案:

没有答案