Reputation: 1
My mathematics (and matlab) is just not up to this and so I humbly ask for your help:
I have a model of flow through a annulus. I want to get the radius of the peak flow point and the radius of the annulus to the centreline.
So, I have 3 points, ABC, in a 3D model whose co-ordinates we know but not aligned to xyz. I want AB to be two points on a plane and point A to be the origin (centre of the annulus). Point C is on a plane parallel to the previous plane (the peak flow point). I would like to know how to calculate the distance between C on its plane to the normal vector of the AB plane that goes through the point A.
Here are pics of the model: Flow through an annulus Points in the model
Now I've had a friend who's cleverer than I come up with a matlab code to translate and rotate the model and then calculate the magnitudes of AB and AnormC. However, it's not working as it puts C at a greater radius than B. I also realise there is more than one way to solve this problem.
The code is below. Any thoughts where we've gone wrong? Or maybe is there a better way to do this? I thought of vectors but my scribblings amount to nought.
Thank you.
Toby
%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
Upvotes: 0
Views: 59