Last active
August 29, 2015 14:22
-
-
Save jnkather/ad01e397e59869b137d2 to your computer and use it in GitHub Desktop.
calculate distance from a given point for a cloud of points, 3D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% JN Kather 2015 | |
% calculate distance from a given point for a cloud of points, 3D | |
% cloud of points | |
Pts = rand(10000,3); | |
% calculate distance from P(px|py|pz) | |
px = 0.5; py = 0.5; pz = 0.5; | |
distance = sqrt( (Pts(:,1)-px).^2 + ... | |
(Pts(:,2)-py).^2 + ... | |
(Pts(:,3)-pz).^2); | |
% plot | |
figure() | |
hold on | |
plot3(px,py,pz,'x','MarkerSize',50,'Color',[0 0 0]) | |
scatter3(Pts(:,1),Pts(:,2),Pts(:,3),25,distance,'filled') | |
hold off | |
view(66,22) | |
grid on | |
colorbar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment