Spacing points on a 2D plot evenly

3 ビュー (過去 30 日間)
francis steyn
francis steyn 2016 年 7 月 30 日
コメント済み: francis steyn 2016 年 7 月 31 日
Hi
Im plotting a 2D closed boundary but the points going around a curve of the boundary are spaced closely to each other. The points on a straight section are spaced further away from each other. The boundary is smooth.
Is there any way to make the distance between each point the same, without changing the structure of the shape?

採用された回答

Walter Roberson
Walter Roberson 2016 年 7 月 31 日
Calculate the distance between adjacent points. Create a cumulative sum of that. Divide the total distance up into as many equal segments as you desire. Use the cumulative sum to locate the adjacent points that each of the equal-length segments would fall between. The difference between the required distance and the point before, divided by the length of the segment, gives you a proportion. The proportion times the delta x and the delta y between the point and the next point gives you the delta x and delta y relative to the first point at which to place your equal-distance point.
  3 件のコメント
Walter Roberson
Walter Roberson 2016 年 7 月 31 日
cumsum()
francis steyn
francis steyn 2016 年 7 月 31 日
Found my mistake, the cases where correct distance is longer than the interval aren't treated.

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2016 年 7 月 31 日
編集済み: Image Analyst 2016 年 7 月 31 日
Yes, John D'Errico has uploaded a function that will be perfect for you. It's called interparc
Be sure to look over all of his other amazing submissions - you'll undoubtedly find other things there that you can use.
  3 件のコメント
Image Analyst
Image Analyst 2016 年 7 月 31 日
Oh, I thought others were allowed to help so that's why you asked here in Answers. But since now you say " I have to write this" (alone), then, good luck with it. Perhaps you're still allowed to follow the general guidelines laid out by Walter.
francis steyn
francis steyn 2016 年 7 月 31 日
My mistake, should have specified at the start, sorry. Yes Walter is on to something.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by