Check for 3D line plot to form a closed loop

7 ビュー (過去 30 日間)
Shalin Parikh
Shalin Parikh 2017 年 1 月 21 日
回答済み: Walter Roberson 2017 年 1 月 22 日
Hi, I am using plot3 command to form a closed loop of points for a code. How can i determine automatically if the points form a closed loop without manually visualizing it. Attached is an example of the points which form the loop. I want to write a piece of code which can automatically determine if the points form a closed loop or not
  1 件のコメント
Stephen23
Stephen23 2017 年 1 月 22 日
Shalin Parikh: do not keep adding identical questions. You can simply add a comment to this question. When you keep adding lots of identical questions it makes it harder for us to keep track of what you have told us and what you have been told. It makes it harder for us to help you.

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

採用された回答

Walter Roberson
Walter Roberson 2017 年 1 月 22 日
The points in your example do not form a closed loop, not as far as well can tell.
The criteria for a set of unsorted 3D points to form a closed loop is this: that there are points that are identical (to within measurement tolerance). In that case, the loop so formed is trivial: there is a path from that point to itself.
To state that the example has a closed loop is to make assumptions of continuity that cannot be inherently justified on an unsorted set of 3D points. A point might look like it is "beside" a different point, but the "real" path might bounce around the rest of the points in strange ways.
One could hypothesize that the set of points might come about by the detection of the edge of a volume, like tracing the edge of a curve in 2D. The problem with that is that when doing edge tracing, it is common to end up with situations such as
A
B
CD
E
F
G
in which case since B is "close" to both C and D, you could say that there is a closed loop between B and C and D.
Sometimes you might be in a situation where you could define your problem as there being deemed to be a closed loop if there is a distance Delta, such that for each point in the set, there are exactly two points that are within Delta of the first point. By the pigeon-hole principle the only way for this to happen is if the "last" point under some sorting is within Delta of the "first" point under the sorting. This criteria in itself does not define one closed loop, though: it says that the graph may be partitioned into a set of subgraphs that have this property, and you would have to go further to narrow it down to a single loop.
In the sample I put above, if Delta is sqrt(2) or more then this criteria would fail because of the close proximity of B, C, D, or C, D, E. If Delta is at least 1 but less than sqrt(2) then the chain from A to F is developing into a potential closed loop (if you were using a program you would have to follow further to see if something looped back to A), but since the F-G distance is sqrt(2) rather than in the semi-open range [1, sqrt(2)), you would have a failure. Therefore even if something continued on in the sample from G back up to A, the above would not qualify as closed loop under this criteria.
This criteria of "exactly 2" is needed to develop uniquely connected chains.
I posted some code a few months ago that would follow chains of scattered points in 2D. Unfortunately I cannot seem to find that posting now :( I remember what the graph in question looked like, but I cannot seem to come up with the keywords to find the posting :(

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by