designcoding
About Table of Contents Keywords Monthly Archive
Support designcoding!

Polar Sorting

September 13, 2026 | Algorithms
#computational-geometry #grasshopper

I’d like to write down an interesting problem here. I remembered this while thinking about this post. It represents one of my favorite, simple pieces of reasoning. I frequently find myself needing to sort a number of points around a center in Grasshopper. Don’t ask why. I realized I’ve been using three different methods to achieve this. The first one that comes to mind is using the Vector Angle component, naturally. All we have to do is supply a plane and two vectors, calculate the angle between them, and sort them. However, in certain contexts, the results of this approach might not be ideal.

Polar Sorting computational-geometry, grasshopper

This is where I thought of using Grasshopper’s parametric curves. A parametric curve always has a direction, a start, and an end. The parameters of points projected (mapped, or pulled) onto these curves give us a perfect ordering under any circumstances. For our specific problem, that curve can be a circle. In short, by projecting the points we want to arrange polarly onto a circle centered at that point, we can use the t output of the Curve Closest Point component. When sorted, the resulting t values will always provide an exact ordering of points (relative to the circle’s drawing plane). What’s interesting here is using a geometric object’s own parameterization to sort other geometric objects. After all, what we call sorting is essentially placing objects into a one-dimensional list. It made me wonder: if we wanted to do a spiral sorting, would we need a 2D sorting? But my mind hasn’t digested that yet.

Polar Sorting Grasshopper definition

The third and most elegant method is the To Polar component, which I don’t use very often. This component directly provides the angle we were trying to calculate above on a polar coordinate system. We solve the problem with a single component. So, how do the performances of these three methods compare? When I built the script and asked it to sort and tag 10,000 points around a center, the computer crashed. Before force-closing Rhino, I read that Rhino was consuming 26 GB of RAM. I hadn’t saved the file. I understood what students feel when similar things happen to them during Rhino exams. Fortunately, Grasshopper created a recovery file right before the final move. I deleted the point-generation and tagging parts and measured just the computational load. Consequently, using the Profiler, I obtained the following results:

Polar Sorting computational-geometry, grasshopper

To Polar component naturally appeared to give the fastest result for arranging 10,000 points. Measuring the vector angle came in second, and the curve closest point method came in last, of course. There are probably even better methods than these. It was an interesting exercise in reasoning.

Grasshopper definition (GH)Download

Cite this post

Yazar, T. (2026, September 13). Polar Sorting. designcoding. Retrieved September 13, 2026, from https://www.designcoding.net/polar-sorting/

Related Posts

Detecting Closed Shapes

August 26, 2013

Again, I continue with some simple solutions for Grasshopper. The surface split component gives all possible surfaces sliced with given curves. And it creates “invalid” curves with at least one open edge. I used this to perceive the closed regions within a given complex curve set. Just put the “Clean” component to erase the outer invalid surfaces and there remain the closed ones. However this time the question was where to put the circle and what its radius of it…

Detecting Inner Regions in Grasshopper

August 26, 2013

This is a simple trick that shows the utilization of the “surface split” component in Grasshopper. It is used for detecting the inner regions of any given two-dimensional linework. Thus, it resembles the hatch boundary detection of AutoCAD and similar software. There is no built-in hatch component in Grasshopper. But maybe you can use this as a starting point if you want to develop it. The definition starts with drawing a circle around a point large enough. The size of…

Curve Farthest Point

August 26, 2013

Today’s tip is about two-dimensional curve-point calculations. It is very handy to use “closest point” components in Grasshopper. You can calculate distances and directions between curves, surfaces, and points. Then, place point objects in relation to the proximity of another object. However, there is no “farthest point” implemented yet. I tried to calculate the farthest point from a curve. First, I tried to translate the curve in a fashion that would result in the opposite of the closest point calculation….

Shortest Path Generator

April 30, 2012

This is the continuation of my scripting experiment within Grasshopper. Like the minimum spanning tree algorithm, this is also a famous problem of computational geometry; the shortest path problem. I’m now coding faster and understanding the namespace more easily in Grasshopper. This time, the challenge was implementing Dijkstra’s algorithm for the Shortest Path Generator. Again, it’s a quite powerful algorithm, I even plan to use it in my current project. Although there is a faster alternative, Shortest Walk-in Food4Rhino and it…

Minimum Spanning Tree

April 26, 2012

This is the updated version of my MST code from 2012. After over a hundred hours of Rhinocommon and Grasshopper SDK studies, and lots of dead ends, I was finally able to calculate the minimum spanning tree of any given curve network in Grasshopper. Problems like these are interesting to me because of their clear logic and diverse areas of applications in design. I tried to simulate Dijkstra’s, Kruskal’s, and Prim’s algorithms, but no chance. There are similar solutions such…

  • Chapters

    • Algorithms
    • Discourses
    • Fabrications
    • Studios
  • Explore

    • All Keywords
    • Table of Contents
    • Monthly Archive
    • #rhino-python
    • #polyhedra
    • #robot
    • #kuka-prc
    • #parametric-surface
    • #tessellation
    • #terrain
    • #boolean
    • #dome
    • #design-object
    • #image-sampler
    • #simulation
    • #vector-field
    • #growth
    • #sandblasting
    • #stone
    • #parametric-curve
    • #animation
    • #cycloid
    • #art
  • Search

  • Support designcoding!

  • Enjoying designcoding? Support me on Patreon to keep it growing. Thank you!

  • copyright 2026 designcoding.net | about | privacy policy | end user license agreement