How can I calculate distance between a point and a line in 4D (or space higer than 3D)?

 Respuesta aceptada

No, there's not, but you can calculate it using the dot product and the norm for any number of dimensions:
numDim = 4;
A = rand(numDim,1); %Point in line
B = rand(numDim,1); %Point in line
P = rand(numDim,1); %Point outside line
pa = P - A;
ba = B - A;
t = dot(pa, ba)/dot(ba, ba);
your_dist = norm(pa - t * ba,2)

Más respuestas (0)

Categorías

Más información sobre Data Distribution Plots en Centro de ayuda y File Exchange.

Preguntada:

el 23 de Mayo de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by