# Distance between points of a 3D centreline

1 ビュー (過去 30 日間)
HB 2020 年 1 月 12 日

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 件のコメント

darova 2020 年 1 月 12 日
What have you tried? Did you try diff function?

サインイン to comment.

### 回答 (1 件)

John D'Errico 2020 年 1 月 12 日

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.

#### 0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。

Translated by