Function Repository Resource:

RandomLoop3D

Source Notebook

Generate a random loop in 3D space

Contributed by: Arnoud Buzing

ResourceFunction["RandomLoop3D"][n]

generates a random loop of n points in 3D space.

Details

RandomLoop3D is similar to RandomWalkProcess in 3D, but forms a closed loop.
All generated points are exactly a unit distance apart from their neighboring points.

Examples

Basic Examples

Generate a random loop of 5 points:

In[1]:=
points = ResourceFunction["RandomLoop3D"][5]
Out[1]=

All points are exactly a unit distance apart from their neighboring points:

In[2]:=
BlockMap[EuclideanDistance @@ # &, points, 2, 1]
Out[2]=
In[3]:=
loop = ResourceFunction["RandomLoop3D"][5];
Graphics3D[{AbsoluteThickness[4], Line@loop, Blue, Sphere[#, .1] & /@ loop}]
Out[4]=

Generate a random loop of 8 points. Sometimes the loop is also a knot:

In[5]:=
loop = ResourceFunction["RandomLoop3D"][8];
Graphics3D[{AbsoluteThickness[4], Line@loop, Blue, Sphere[#, .1] & /@ loop}]
Out[6]=

Publisher

Arnoud Buzing

Requirements

Wolfram Language 14.0 (January 2024) or above

Version History

  • 1.0.0 – 23 October 2024

Source Metadata

License Information