Mesh - Edge normal vector

Hello, all you grasshopping rhinos!

I’m new to Grasshopper and I can’t figure something out…

I’ve generated a triangulated mesh and extracted all the faces, edges, vertex normals and face normals. The one thing that I really need but can’t get are the edge normal vectors.

I can calculate this vector but how do I return the faces of a shared edge?

Is there maybe a plugin for this? Rhino 8, btw.

Thank you in advance!

There used to be the Sandbox plugin but you can use a small script too.

I think Daniel Piker posted this a while ago.

File with c# script which outputs internal edges and indices for left and right face:

mesh_angles_c.gh (31.2 KB)

This one here uses a kangaroo component to get the hinge points:

mesh_angles_gradient_c.gh (39.2 KB)

Thank you very much! This is the magic I needed!

1 Like

See attached as well (conn is about the adj Faces indices).

Mesh_EdgeNormals_V1.gh (128.3 KB)

This is so close to what I need to do, but I’m finding it very hard to reverse the flow of information so that I can manipulate the edges and reconstruct a mesh based on the original topology.

In this example, I’m offsetting each edge along its normal and shrinking it to form a truncated triangle. It’s easy enough to generate the “side walls” but the blue “top face” eludes me.


(Let’s not worry about the little truncation faces at the source mesh vertices for now!)

The C# component reports “connTree” which is a tree of edges, each leaf being a list of faces belonging to that edge. What I want is the opposite: A tree of faces, each leaf being a list of edges belonging to that face. I’ve marked up this transformation by hand here:

Any help very much appreciated!

(GH file contains one Mesh+ component)
Simple tile.gh (13.6 KB)
simple tile.3dm (101.8 KB)

See attached (elementary Mesh Connectivity stuff + Mesh Topology Vertices Sort - an existed/handy RC Method that one).

Mesh_EdgeNormals_V1B.gh (142.4 KB)

BTW: if you want a “moved” Mesh collection (i.e. 6 tri Meshes from the “upper” 6 points) on a per Face basis … notify.

1 Like

I’m supposing you were hoping for a coding solution?

1 Like

That works really well, cheers! Butl if you’re offering to code to order, I’ll be a bit more specific, because that “moved” mesh collection is really what I’m after and all the other bits (edge quads, vertext tris) I can do myself, (along with anything else that might crop up as I develop this thing).

The less that ends up buried in an opaque (to me) C# component the better tbh!

The only other change I’d need is for the edge shortening effect to be a linear subtraction from each end rather than a scaling effect (I was using Extend Curve with a negative value in my original). This is important for manufacturing reasons I won’t bore you with.

hah! no, if anything I prefer keeping things in component land. I’ve tried learning to code many times in my life at this point and I keep bouncing off. I just get lost in the abstraction (despite knowing full well that abstraction is what makes it a better and more flexible approach).The visual nature of grasshopper, and other node-based editors, is an absolute godsend for my kind of brain.

I’ll give your solution a go :slight_smile: cheers!

EDIT: Ah so that’s what Sets are good for!"

Just don’t connect the panels to inputs… I’m still looking for a way to avoid the flip matrix component.

1 Like

Alas, I get some exceptions. The majority of the edges come out of Peter’s C# component in the same order, but a handful are different. When I try and create meshes from them, I get these self-intersections as a result:

I think my fate lies in Peter’s hands now…

Simple tile 2.gh (18.1 KB)
simple tile 2.3dm (283.8 KB)

Are you just trying to offset the surface and put holes at the vertices?
And do you need the surface as a mesh?

Well, I didn’t know how to offset the mesh, so if you are willing to use the Pufferfish plugin for its Offset Mesh component, this will create you your mesh:


Simple tile 3.gh (26.9 KB)

The holes are a by-product really.

If my source was a flat plane or a sphere or a torus, then every face would have similar vertex normals and an Offset Mesh would then also have identical edge normals resulting in coplanar edges (left). But when the vertex normals are all over the place, it twists the resulting edges (right).

I need those quads to be planar for Reasons, so I’m sacrificing vertex continuity to achieve it.

Well … in the latest C# attached that works by computing pts - given the Edge diherdral Vector3d as the unitized sum of the adjacent Faces normal Vectors - on both sides of the Edges (i.e. Line.PointAt(at), Line.PointAt(1 - at)). The at var varies from some small value (say 0.05) to 0.5 - that small value. So … I’ll replace the at var with some real-life value (but this requires more checks: you should restrict the value in order: 2*value + some pragmatic minDist <= Edge Length - plus you’ll need some report - per Topology Edge index - if the value is not appropriate for a given Edge).

Other than that I’ll add some lines more in order to get the “moved” combo of the 6 meshes

1 Like

Yes, I already have some edge length checking in the main project and the subtraction amount is limited to a fraction of the minimum reported length. Thanks for your help!

I am so confused.

What quads?

The ones that join the edges of the source triangles to the edges of the offset ones.

This is a problem fundamental to offsetting meshes. The standard approach is to move each source vertex along its normal and remake the mesh using the new positions.

If the source is a flat plane of faces, then the offset mesh is identical and creates perfect prisms with rectangular sides (the quads in question).

If the source has uniform curvature - the surface of a cylinder for example, then each face offsets to a larger copy of itself and creates fustrums with flat sides.

But my source has non-uniform curvature. When you offset along each vertex normal, the edges of the new offset mesh are no longer parallel with the source.

My solution is to offset edges along their normals instead. Normally this would create intersections where curvature is concave, so I’m truncating the edges to allow for it.

The resulting “pits” at each vertex are an aesthetic feature, not a bug :slight_smile:

Oh. Thank you for the pictures and longer explanation. That explained things very clearly to me.

1 Like

Found some minutes to add the “moved” meshes option (i.e. 6 on a per Face basis).

Mesh_EdgeNormals_V1C.gh (142.4 KB)

Anyway it’s unfortunate that you can’t code: things like these are elementary - more or less.

1 Like