Clear Filters
Clear Filters

Finding all coordinates in a 3mm radius of a given point in a 3D Co-ord system

4 views (last 30 days)
Pelvis file has a matrix el that is a 311250 x 4 matrix
1 150.4361 272.835 494.732
2 145.5447 272.5184 501.3505
3 105.663 206.3669 616.0499
4 149.2675 266.5884 499.2084
5 146.939 269.4385 495.2123
6 146.9607 268.4392 494.6038
7 120.3481 237.3924 536.6527
8 186.364 230.3899 516.2784
9 150.0968 271.23 493.7704
10 149.3508 272.4526 495.4274
11 122.7781 223.1231 595.5535
Etc.... (goes on to node number 311250)
The above coordinate system is a section of a pelvic bone that is being modelled. We are generating lesions (modelled as spheres) in this pelvic bone to be analysed.
Using the below code i have random seleted a node from a 3D Coordinate system to be the origin point of a sphere.
load pelvis.mat;
a = el(:,1);
b = a(1);
c = a(end);
n = randi([b,c]);
Node1 = el(n,:); % node1 indicates the origin point of the lesion
I am wondering how i would find which nodes are within this sphere? And output just these nodes.
I am not able to attach the pelvis.mat file unfortuantely i aplogise for this

Answers (1)

Image Analyst
Image Analyst on 16 Dec 2020
Looks like you blew right past the posting guidelines. You forgot to attach 'pelvis.mat' and forgot to enter your release/version. Here's another chance to read them: Click here
After you've read that, please attach pelvis.mat so we can help you. Make it easy for us to help you, not hard.
Since you have a list of [x,y,z] values, and a center value [xCenter, yCenter, zCenter], I'd just compute the distances
distances = sqrt((x - xCenter).^2 + (y - yCenter).^2 + (z - zCenter).^2);
% Find out which distances are less than, say 30 pixels;
closeRows = distances < 30;
% Extract new vectors that are only those that are closer than 30 pixels.
x2 = x(closeRows);
y2 = y(closeRows);
z2 = z(closeRows);
Now be aware that 3-D images are indexes like m(y, x, z) which is m(row, column, slice), NOT m(x, y, z);
y is the first index, not x!

Community Treasure Hunt

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

Start Hunting!