# Calculate the angle between edges/straight curve segments joined at a point with geometry nodes

I've been struggling with below for a while and hoping someone can shed some light on it.

I have a collection of edges (originally from curves, they are straight and have no mesh face) and I want to calculate the angles alpha and beta shown below.

These are labeled Edges 1, 2 and 3 in the image, but the ordering is not set. The are cases where there are only two edges and I need the angle between them but the case shown in the image is more general. I should also add that there are multiple other edges far away in the total input, but I think I can figure out how to isolate these specific edges on my own.

To be a bit more rigorous, I only want the angle between an edge and the next edge such that the angle is smallest - for example, from Edge 1, I don't care about the angle to Edge 3, only that to Edge 2.

The angle calculation itself is some pretty straightforward maths, but the part I'm specifically having trouble with is isolating the specific edge I want to find the angle to.

Markus has a great answer here on the problem of finding the nearest edge of a neighbouring mesh island, but I'm not really clear on how this can be modified to work with edges that exist independent of a face (if that even makes sense - I'm a bit vague on the terminology). I couldn't find a straightforward way of even referring to edge indices and feel like the solution will involve some degree of switching between mesh and curve representations of these objects.

I considered converting these to mesh and then using geometric proximity or sample nearest, but then got lost in the weeds of trying to keep track of which derived mesh came from which edge trying to trick Blender into doing what I want.

As a footnote, I'm still a bit of a beginner to geometry nodes, so some explanation of the logic required to achieve this I'd be greatly thankful for but is by no means required.

Any help offered would be sincerely appreciated.

• is alpha and beta always "just" the z-angle or the "real" angle in 3d space? Feb 8 at 6:37
• Real angle in 3D space - apologies, this was not clear in the original post. I was just going to use arccos and two normalised vectors to get the angle. The problem is getting those vectors in the first place. Feb 8 at 6:43
• I think you need to be more specific: e.g. 'I want the signed angle to the next clockwise edge, viewed from the N direction, stored on each edge' .. or.. 'I want the smallest adjacent angle, stored on each vertex'.. etc. Feb 8 at 9:13
• It's quite complicated, I've stuck. @quellenform, can you look at this? It worth looking Feb 8 at 9:26
• @RobinBetts Makes sense - I come from a more PCL background rather than Blender and am not sure how to be more specific... I would say that I'm after the angle to the next edge going clockwise about the point, viewed from +Z, stored on each edge. These edges are not exclusively in the XY plane but have small Z variation, however the plane formed by any two edges' normal will always result in a positive dot product with +Z. Feb 8 at 9:26