# Mesh entities- Ngon problem

I made an update to NGon plugin that allows to get these values directly for polygonal meshes including triangles, quads, hexagons and etc:

Be aware that for open meshes, the orientation of mesh matters.
Sometimes you need this information sometimes not.
If you do not need it then you can take modulus of 180.

I updated current version of NGon (3.0.0) that includes this property:

Example File
Sample.gh (19.6 KB)

For sure this angle notation makes sense when polygons are planar or at least close to planar.

``````public static double AngleBetweenTwoFaces(Plane plane0, Plane plane1, Point3d edgeMiddlePoint) {

if (plane0.ZAxis.IsParallelTo(plane1.ZAxis, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance) == -1)
return 0;

if (plane0.ZAxis.IsParallelTo(plane1.ZAxis, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance) == 1)
return 180;

double num = Math.PI - Vector3d.VectorAngle(plane0.ZAxis, plane1.ZAxis, new Plane(edgeMiddlePoint, plane0.ZAxis, plane1.ZAxis));

//Solve concave / convex cases

Vector3d v = plane1.Origin - plane0.Origin;
double angleBetweenMidPoints = Vector3d.VectorAngle(plane0.ZAxis, v, new Plane(edgeMiddlePoint, plane0.ZAxis, v));

if (angleBetweenMidPoints > Math.PI * 0.5)
num = Math.PI * 2 - num;

num = Math.Round(Rhino.RhinoMath.ToDegrees(num), 3);
return num;
}
``````
4 Likes

Fantastic! Thank you!

1 Like

This is really useful. Thanks!

1 Like

Can you explain what does it mean to install via Yak with on click?
I am trying install it via Food for Rhino, but there is no info regarding YAK.

I need to push on yak so that it would be available on this platform too.
By yak, I mean rhino command PackageManager.

So for now download 3.0.0 v. from food4rhino and unblock zip file. All files should be unblocked that way.

Looks like Petras has a solid component that does edge angles.

I thought I would add this old school arc method I arrived at in the ye olden days.

1 Like

I am trying to understand you wrote but it is not clear for me being not a developer. You say on Food for Rhino: “Add library files to: …\AppData\Roaming\Grasshopper\Libraries and unblock them.”
I attach a screenshot of the downloaded files. Can you tell me which of the considered “LIBRARY FILES”? All of them or just some .dll or .gha or all folders ? Actually it is general problem what most not pro users facing when they try to use add -ons. Most of them install similar but not exactly similar, and most developers write very little or nothing at all about installation. I think on FOOD for Rhino should be rules made for every add-on. One of the rules should be that at the very beginning of the descriptions should be a detailed description of the installation. Actually I have picked 4-5 add ons randomly and none of them had installation description.

Ah, back when we had to use actual string to connect components together! Thems were the days!
I’ve done this for a geodesic dome before; it gave me a headache and I never trusted the definition enough for other meshes. It’s nice to see some off-the-shelf solutions for this sort of thing together with the mesh planarisation and conicalisation abilities in Kangaroo… One day I will build something in the real world!

locate the zip file you have downloaded from Food4Rhino, should be called “ngon3.zip”
right click on it, and select “Properties”
it will appear a window like the following: CHECK the checkbox that says “unblock content”, then click Apply, then click OK

now open Rhino and Grasshopper, go here and click this:

windows will open the file browser at the location where your Grasshopper plugins are installed, probably something like
C:\Users\YourName\AppData\Roaming\Grasshopper\Libraries
there might be other files and folders here, depending on what plugins were manually installed

just create a brand new folder, and name it Ngon3

now open the ngon3.zip file you have previously unblocked, and drag ALL the contents inside the folder Ngon3 you have just created

close Rhino and Grasshopper, open Rhino and Grasshopper again to have Ngon3 loaded

1 Like

I have followed the instructions. Unfortunately after the installation I got errer messages when I open some of the previous files containing Ngon widgets. Is it ok like that?

That is fine. These are just warnings saying that I changed few outputs in the components.

Can you please what is the function of these two widgets?

The first one reverses ngon vertex order:

The second one unifies polygon edge order so that every neighbor edge is flipped, similar to half-edge data-structure:

These operations are needed depending on algorithms you use for the meshes that must correspond to edge ordering or do not care.

For instance, we could not create proper indexing on each cardboard panel until the mesh was properly ordered that has quite an important role for assembly since you cannot follow computer screen anymore:

And the NGon installation tutorial is here:

2 Likes

I have just noticed that the some of the quads are not planar in my bear mesh. I thought it is high time to try some of the planarize functions. I cut out a portion from the bear for experimenting. I had no success. Even if I am playing with the RUN and Reset booleans, nothing happens. Actually it worked for the very first time and the counter displayed a value but then I changed the iterations and since then I cannot run it again.

PLANRIZE.gh (9.0 KB)

The polygons can also be simply planarized like this:
planarize_bear.gh (14.1 KB)

thank you!

1 Like

# NGON dihedral angle problem

I’m sure Petras can help with how to do this with his components specifically, but if you just want to get the signed dihedral angles between each pair of adjacent faces of a triangular mesh, this is a simple way:
fold_angle.gh (9.6 KB)

@DanielPiker awesome! the angle calculation is pretty fast, any chance to remove the extra edges your component generates because of the triangulation and also to extract the centre and normals from the faces pair. I tried to use the closest point evaluation but that’s too heavy, maybe an addition to your method would be helpful to generate the hinge angles just with the face normals, not necessarily planar, thank you!

@Petras_Vestartas, your plugin works quite well, but I don’t think it’s worth using a Ngon method to work with a simple mesh (quads and triangles), I think with a heavy mesh a mesh method could be faster. But don’t get me wrong, thank you for all your awesome tools!

meshangle.gh (36.1 KB)

Hi @ThomasE

All you really need here are the indices of the 2 adjacent faces for each internal edge, separated consistently into left and right when looking along the direction of the edge.

(this last part is critical to be able to tell the difference between mountain and valley folds as in origami, which was my original motivation for making this component)

This just takes a couple of lines of code, and then you can use these indices to do all sorts of things - getting signed dihedral angles, creating dual edges, getting edge normals etc.