<p>If projecting them onto the plane of the vertex normal doesn't do the job, I'm not sure what would. There isn't any unambiguous way to do this in 3D. Imagine the new triangle that you are on there joining is perpendicular to the existing two triangles? What would you want the answer to be in that case?</p>
<p>I suppose you could try &quot;voting&quot; by dotting the new triangle's normal with each of the existing triangle's normals. A positive dot is a vote to keep the current orientation, a negative dot is a vote to flip it. Maybe weight the votes by the triangles' areas, or their angles at that vertex. Of course you'd have to decide how to break ties, and this might just give you similar problems to the plane of the common vertex normal.</p>
<p>This would make more sense if you were constructing a new triangle that shared an edge with one of the existing triangles. Then you could copy the orientation from the triangle that it was joined to. I'm not sure what kind of 3D modeling operation you're doing that produces this situation, but if there's any way you can accomplish it by building things in terms of common edges rather than common vertices, you'll probably have a much better time.</p>

CC BY-SA 4.0
2020-09-22T18:19:48.420Z
2020-09-22T18:19:48.420Z
Nathan Reed
<p>I'm trying to figure out this problem for very long time and am no getting nowhere. I'm working on a simple 3d modeler that uses half-edge data structure.</p>
<p>Say I have non-manifold geometry where two triangles share a common vertex, as shown in the image below. And I want to add another triangle such that now three triangles share a common vertex. Once we add the new triangle we need to reorder the half-edges around the common vertex. In 2d this ordering is done by sorting the half-edges from the common vertex clockwise, as explained in <a href="https://cs.stackexchange.com/questions/2450/how-do-i-construct-a-doubly-connected-edge-list-given-a-set-of-line-segments?newreg=1d611fc139b64175a8ba4ba0823ba6be">this</a> post.</p>
<p>However in 3d this becomes a nightmare. If the same three triangles share the common vertex but have an arbitrary orientation in 3d space and are not coplanar. How can one possibly sort the half-edges?</p>
<p>I experimented with using the common vertex normal to construct a plane, and project all the half-edges around the vertex to that plane. After which we could sort them clockwise relative to the plane. But I've found this approach to have a lot of issues. And now I'm all out of ideas.</p>
<p><a href="https://i.sstatic.net/pQyab.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pQyab.png" alt="enter image description here" /></a>
<a href="https://i.sstatic.net/WHSSF.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/WHSSF.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2020-09-21T05:07:41.673Z
do you want to generate the traslation ?
information
CC BY-SA 4.0
2021-01-14T19:08:34.737Z
Cross-posted: https://computergraphics.stackexchange.com/q/10246/2911, https://cs.stackexchange.com/q/130326/755.   Please [do not post the same question on multiple sites](https://meta.stackexchange.com/q/64068).
D.W.
CC BY-SA 4.0
2021-01-16T16:08:08.017Z
Closing here for cross-posting on Computer Science SE. Please take a look at the meta question @D.W. linked and do not cross-post in the future.
wychmaster
<geometry><mesh>
Sort half-edges around common vertex in 3d
Lenny White
# Sort half-edges around common vertex in 3d

(Asked by: username_0 on 2020-09-20)

I'm trying to figure out this problem for very long time and am no getting nowhere. I'm working on a simple 3d modeler that uses half-edge data structure.

Say I have non-manifold geometry where two triangles share a common vertex, as shown in the image below. And I want to add another triangle such that now three triangles share a common vertex. Once we add the new triangle we need to reorder the half-edges around the common vertex. In 2d this ordering is done by sorting the half-edges from the common vertex clockwise, as explained in [this](https://cs.stackexchange.com/questions/2450/how-do-i-construct-a-doubly-connected-edge-list-given-a-set-of-line-segments?newreg=1d611fc139b64175a8ba4ba0823ba6be) post.

However in 3d this becomes a nightmare. If the same three triangles share the common vertex but have an arbitrary orientation in 3d space and are not coplanar. How can one possibly sort the half-edges?

I experimented with using the common vertex normal to construct a plane, and project all the half-edges around the vertex to that plane. After which we could sort them clockwise relative to the plane. But I've found this approach to have a lot of issues. And now I'm all out of ideas.

[![enter image description here](https://i.sstatic.net/pQyab.png)](https://i.sstatic.net/pQyab.png)
[![enter image description here](https://i.sstatic.net/WHSSF.png)](https://i.sstatic.net/WHSSF.png)

**Tags:** geometry, mesh

> **Comments:**
> **username_1**: do you want to generate the traslation ?  
> **username_2**: Cross-posted: https://computergraphics.stackexchange.com/q/10246/2911, https://cs.stackexchange.com/q/130326/755.   Please [do not post the same question on multiple sites](https://meta.stackexchange.com/q/64068).  
> **username_3**: Closing here for cross-posting on Computer Science SE. Please take a look at the meta question @D.W. linked and do not cross-post in the future.  

---

## 1 answers

### Answer by username_4 on 2020-09-22. Score: 0

If projecting them onto the plane of the vertex normal doesn't do the job, I'm not sure what would. There isn't any unambiguous way to do this in 3D. Imagine the new triangle that you are on there joining is perpendicular to the existing two triangles? What would you want the answer to be in that case?

I suppose you could try "voting" by dotting the new triangle's normal with each of the existing triangle's normals. A positive dot is a vote to keep the current orientation, a negative dot is a vote to flip it. Maybe weight the votes by the triangles' areas, or their angles at that vertex. Of course you'd have to decide how to break ties, and this might just give you similar problems to the plane of the common vertex normal.

This would make more sense if you were constructing a new triangle that shared an edge with one of the existing triangles. Then you could copy the orientation from the triangle that it was joined to. I'm not sure what kind of 3D modeling operation you're doing that produces this situation, but if there's any way you can accomplish it by building things in terms of common edges rather than common vertices, you'll probably have a much better time.


---

