Distance between points of a 3D centreline

1 visualización (últimos 30 días)
HB
HB el 12 de En. de 2020
Editada: John D'Errico el 12 de En. de 2020
Hello,
I have a curve represented by 3D points (please see attached .mat file). I would like to find out the distance between the 1st point and the 2nd point, the 2nd point and the 3rd point, the 3rd point and the 4th point, the 4th point and the 5th point ect until the final point and the values be saved to a text file.
What would be the simplest most accurate way of achieving this? Any suggestions welcome.
  1 comentario
darova
darova el 12 de En. de 2020
What have you tried? Did you try diff function?

Iniciar sesión para comentar.

Respuestas (1)

John D'Errico
John D'Errico el 12 de En. de 2020
Editada: John D'Errico el 12 de En. de 2020
Why not try diff? For example, what does
diff(CL,[],1)
do? TRY IT! What is distance? Does that give you something you might be able to work with? Does it get you closer to the goal that you need to achieve?
What if you then squared the elements of that array? Again, THINK! TRY IT!
diff(CL,[],1).^2
Suppose you now used sum on the result?
sum(diff(CL,[],1).^2,2)
what does that represent? Now, again, what is the distance you are trying to achieve? Would a sqrt help here? TRY IT!
When you have a difficult problem, break it into small pieces. Try to move towards the goal you want. Look for functions that will help you to acheive that goal. While it is often unlikely that you will find one magic function that does exactly what you want, it is also the case that very often, you can find several functions that will get you there when taken in combination.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by