필터 지우기
필터 지우기

Extracting points from a matrix tangential to a centreline

조회 수: 2 (최근 30일)
HB
HB 2020년 3월 13일
댓글: darova 2020년 7월 8일
Hello,
I have a tube with two branches (please see attached point cloud showing this model where the columns are x y z and a variable respectively). I also have a centreline that runs through the main branch of the model. Please also see attached centreline points where the columns are x y z respectively. I have also attached images showing the model and centreline. The red outline drawn on the model geometry highlights where the main branch is located.
At each centreline point I am trying to extract the points located tangentially along the model to that centreline point to a new matrix along with their corresponding variable value. I have attached two images that hopefully clarify better what I want to achieve. I am pretty new to Matlab so in depth explanations would be great.
Thanks in advance.
  댓글 수: 6
darova
darova 2020년 3월 15일
Maybe better be to use pdist2. IT calculates every possible combination of distances
You have two set of data (46 and 113502). So it creates matrix of size 46x11502
Try this
D = pdist2([CLx CLy CLz],[geomx geomy geomz]); % matrix of size 46x113502
D1 = D < 2; % distances smaller than "2" (matrix "0" and "1")
[~,ix] = find(sum(D1)>0); % if columns has one "1" - find it
plot3(CLx,CLy,CLz,'r') % centerline
hold on
plot3(geomx,geomy,geomz,'.b') % all data
plot3(geomx(ix),geomy(ix),geomz(ix),'.r') % data close to centerline
hold off
HB
HB 2020년 3월 16일
편집: HB 2020년 3월 16일
Great!
So D1 now contains all the points excluding the side branches and points outside the centreline (see attached). What would be the best way to now get the cross section points at every centreline point as seen in desired_output?
Thanks!

댓글을 달려면 로그인하십시오.

답변 (2개)

darova
darova 2020년 3월 16일
Here is what i did
I moved data to origin and rotated at some points of centerline
Once centerline is vertical i extract data -1<z<1 (for example)
I created surface at some points of centerline
countour was used to get crossection
I used Rodrigues rotation matrix/formula to rotate data
Result
See attached script
  댓글 수: 3
darova
darova 2020년 3월 17일
To write data
DATA = [];
for i = 1...
% code
V(:,1) = [];
DATA = [DATA V'];
end
dlmwrite('myFile.txt',DATA,'delimiter','\t')
  • and their corresponding variable value which are located in geom_variable(1:1:end,4)?
Im afraid crossection line doesn't have corresponding values of geom_variable.
Closest points/values (red) can be found. But it's always different number
Change these lines in a loop
ix = abs(V(3,:)) < 0.1; % data for crossection creating
length(find(ix))

댓글을 달려면 로그인하십시오.


HB
HB 2020년 3월 17일
편집: HB 2020년 5월 4일
Ah I see, what I need is cross sections that consists of points from my geometry and the corresponding variable which is shear stress. The data is actually an artery model from a CFD.
What does the values length(find(ix)) values refer to? And how would I export the points shown in your latest plot?
Thanks
  댓글 수: 30
HB
HB 2020년 7월 8일
편집: darova 2020년 7월 8일
Hello,
Hope you’re well!
I’ve been running cases with the latest script (see attached crossection_latest.m). It seems able to extract some cross sections but not others. For instance if I change line 26 from “i = 1:5:size(CL,1)-1” to “i = 1:size(CL,1)-1” therefore to include all the cross sections I get the error:
Error using linspace (line 22)
Inputs must be scalars.
Error in crossection_latest (line 43)
zz = linspace(min(gz1),max(gz1),10);
Any suggestions on how this can be overcome this (I have attached the files for a case)? It happens for a few of my cases, many thanks in advance!
darova
darova 2020년 7월 8일
Hello!
I think the problem you described is cause by radius you choosed. You didn't found all the points of an arteria
ix = sum(D<2) > 0; % if columns has one "1" - find it
You arteria is thicker than you think. Try to increase the radius
ix = sum(D<2.5) > 0; % if columns has one "1" - find it

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Vehicle Scenarios에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by