# How do I get the coordinate where an edge intersects a face using geometry nodes?

Using geometry nodes, is there any way to detect where an edge intersects with a face? It's difficult for me to explain. But I drew a picture. The gray line is merely an edge, and it intersects a face of a mesh, as indicated by the gray circle. Is there a way to get the vector of that circle? I figure if I knew what that vector was, I could move other points toward or away from it. Oh, and I would really prefer it if both the mesh and the edge are of the same object. Not two different objects. One object's edges, detecting the faces of itself. • This question is actually unusually clear. Thank you! +1. Jul 5 at 16:07

To solve this task you could use the node Raycast.

By subtracting the two positions of your mesh line from each other you get the direction, and starting from one of the two positions you can then send a raycast to the grid.

Something like this: It depends on what exactly you are planning or how you want to set this up, but in that case it seemed to make sense to me to capture the hit directly on the mesh line, convert it to a point, and then move the point to the position where the grid is hit.

Update

To solve your specific task and to be able to process everything in a single object, you would have to define more precisely what your plans are.

There are many possibilities here, and the structure of the solution depends primarily on the domain in which you need the information of the intersections.

However, I will try to illustrate a possible solution with the following example: Here I use basically the same mechanism as shown in the previous example.

However, I send the raycast in the length of each edge, starting from each point, in both directions.

Thus it is possible to find also the intersections of more complex shapes (but always only maximum twice along an edge).

• That's one way of doing it. Thanks. But can you do that with only a single object? The drawing of the grid and the edge was only to simplify the idea. But think how an object might fold in on itself. Its edges would intersect it's own faces. How would you get those intersecting coordinates in that case? Jul 5 at 18:09
• @Smeebit Well, there are many possibilities. To be able to answer your question more precisely, one would have to know more about your use case, but I have now tried to illustrate another possibility in an update. Jul 5 at 18:58
• The update is very good. I would have never in a million years thought to do any of that. It's going to take me a while to even wrap my head around what you did exactly. So I'm just going to play with this node tree for a while. In the mean time, I'll tell you what I'm attempting. Ultimately, I'm thinking of a method for simple self collision. I figure that if the edges can detect when they're intersecting faces, then from there, the vertices of the edges could be moved either back or forward to a point where they no longer intersect. The whole idea is very slippery in my head. Jul 5 at 22:13
• @Smeebit Ah, now I understand, that sounds interesting! However, for this I would recommend you to create a new question in order not to steer this topic ("How do I get the coordinate where an edge intersects a face using geometry nodes? ") into another direction. You can then refer to this thread for a better explanation. Jul 5 at 22:31
• After months of experimentation, I'm almost entirely certain that raycasting won't serve my purposes. Would you happen to know a way to attain the "hit position" without raycasting? Any way through curve or mesh, of getting the vector where an edge intersects with a face. Perhaps there is a way to do it with math? Please and thanks. Nov 18 at 7:31