algorithmic modeling for Rhino


Can anyone help with creating planarization in vb? I would like to create a component that planarize in a loop. And I just do not know any theory to start - I would appreciate any clue

(while I have experience in planarazing using kangaroo and kangaroo2)

Views: 545

Reply to This

Replies to This Discussion

What do you want to planarize specifically? project the whole mesh to a plane? some faces with some planes? or do a concatenation of forces like makes kangaroo? ...?

Definitely something like kangaroo. To input the generated mesh with many nonplanar faces and recieve a planar one, as a result of forces/vectors

Ah, maybe you should use the Kangaroo library.

I've never tried to do this from scratch, but I would do something like:
- An iterative method that minimizes the error (in each iteration, the faces are more flat);
- It may not, but for start, I would use the normal vector of each vertex as the freedom to move. And what must calculate is the correct amplitude of the vector.

Then, as a first glance, the logic might be:
ErrorGlobal as new double
Count as new integer
A tree that stores, for each vertex, a list of vectors.
Per face:
  Plane from point cloud.
  For each point of the face:
    Projecting the point to the plane and the distance is the factor error. You need to know if the value is positive or negative.
    Add the vector (vertex - Project vertex) to the tree. the branch is the index of the vertice.
Per vertex:
  Making the average of the vectors in the respective branch in the tree.
  Move the vertex of the mesh with the average vector.
errorglobal += vector length
errorglobal / = vertices.count 'Average error or another way to see.
count + = 1
Loop while errorglobal> 0.01 or count <1000

I doubt this will work, really, as I said before, I've never done this. But it can be a start... Good luck.

Is it important that you do it from scratch yourself? There ends up being quite a bit that you need to resolve, which is why a library like Kanagroo is so useful. For example, Daniel Abalde's suggested approach here would be effective for moving vertices in your n-gons toward planarity...however, you'd also have to consider how your geometry would deform as it did so. Your interior angles and edge lengths along your n-gons may be become unrecognizable without any means for them to "try" to maintain a semblance to their original geometry: they will only obey the imposed desire to planarize, while flying every which way. Daniel Piker has opened up Kangaroo2 as a .NET library, so you can use its integration power to reconcile all of these considerations. It comes with all of the "goals" you'd need to do a straightforward planarization script on your geometry, such as line-length, angle, planarization and anchor goals. He's even set it up that you can build your own goals using an interface, which is for sure more advanced, but opens up all sorts of form-finding possibilities.


Thank your for your reply. I know kangaroo 2 well, we have done some fabrication project with it and used a lot of angle, length, planar etc. goals. I will publish some video soon. I have also tried, but only a bit, its scripting capabilities. I know how cool is it and I love it a lot

But right now i learn a lot of scripting in vb in gh and try some things. We have done some subdivisions in the office so I thought it would be cool to add some custom planarization to our vb scripts. But well, sad to hear, but if it really is so sophisticated maybe it is waste of time to try. Especially that i have found no examples of anyone doing it in vb/c# in gh.... 

But still being curious - do you know maybe what is the worflow to planarize quad meshes in processing? Toxiclibs or something? Did anyone try it?

Hi Aleksander - I think this is a good exercise to try.

Dave makes good points about the need for some sort of fairing/regularization and other constraints to go along with the planarization. Without these, unless the mesh starts out pretty close to planar the faces can quickly become very distorted and even self-intersecting. However, if you stick to meshes that are already nearly planar, and do not require to combine it with other constraints, then something like what Daniel Abalde describes could work - just project each point of each face to that face's best fit plane, then average the results to recombine the vertices, and repeat.

With mesh planarization getting the right topology for the initial mesh is often a large part of the challenge.

Don't give up! This sounds like a great challenge for getting into scripting, and the Kangaroo2 library is really great. Have a look at some of the scripting examples that Daniel has provided to get started with it. They are in c# but could easily be ported over to

Thank you guys. I have done that. It works very well. Obviously with messed up geometry it produces very messed up result, but regular or just well designed meshes work perfectly


Hi Aleksander,

would you mind to share the code?

Next step that I am trying to do is to incorporate two other things:

1. Constraining some vertexes as immobilized. I have allready implemented it but it produces some unexpected results

2. Add face smoothing (smoothing face normals). 

Do you have any ideas?






  • Add Photos
  • View All

© 2020   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service