Filter löschen
Filter löschen

Measure the distance of multiple spots to a several line segments

1 Ansicht (letzte 30 Tage)
Matthew
Matthew am 22 Okt. 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);

Antworten (0)

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by