Measure the distance of multiple spots to a several line segments

1 vue (au cours des 30 derniers jours)
Matthew
Matthew le 22 Oct 2015
I have 2 populations of 3D points placed on opposite sides of an volume (3D). I want to draw an orthogonal line from each point from the top population, along the z-axis. Then find the spot in the lower population that is closest to the line. Then measure the distance between each of the points.
I would like to be able to vectorize this, as the number of spots could be very high.
I have used this code below to measure that distance from the first point in P to a the line Q1Q2. I can make a for loop, but that is not very efficient. An help would be appreciated.
Q1=vVertices1(1,:); %contains 2000points
Q2=vVertices1(1,:);
Q2(:,3)=Q2(:,3)+1000; %To generate orthogonal line
P=vVertices2(1,:); %contains 2000 points
dist = sqrt(norm(Q2-Q1)^2*norm(P-Q1)^2-dot(Q2-Q1,P-Q1)^2)/norm(Q2-Q1);

Réponses (0)

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by