How to find "twin" of half edge?

geometry
half-edge

#1

I am trying to construct a HalfEdge data structure with the vertices data of my BufferGeometry.
Using the implementation in examples/Quickhull.js, I managed to construct an array of Faces that each contain a starting HalfEdge. I can then call HalfEdge.next() and again to find all three HalfEdge that make up a given Face.

The problem is, given a Face, I can find out what HalfEdges compose that face, but I cannot find any adjacent faces because my HalfEdges are missing the “twin” data.

How can I traverse through my HalfEdges and match a “twin” HalfEdge for each?

Here is a fiddle that I made to illustrate my problem.
https://jsfiddle.net/z9v8f7qb/31/


#2

You have to set the twin reference by yourself when constructing objects that represent the topology our your geometry. That means you have to know what faces are adjacent and should logically be connected. Setting a twin edge is done via HalfEdge.setTwin().


#3

Thank you for the reply. I was aware of the setTwin method, but I was wondering how I should find the HalfEdge to set as a twin.

I thought of looping over all HalfEdges, and try to match up those that share any two vertices. Is this the only way to find the twin for a given HalfEdge?


#4

There might be situations in algorithms where you know that two faces are adjacent so you can connect them via half edges. In all other cases, it is actually necessary to do it like you suggested. So comparing edges based on their from and to vertices.

You might want to perform the compare operation with an epsilon value in order to mitigate floating point precision issues.


#5

Alright. Thank you for the responses!


#6

/cc


#7

Thanks for the reminder! Totally forgot about this.