• ### What is your GameDev Story?

This topic is 3860 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Okay so let's say I have a triangle (in 3d), and I'd like to find all 3 possible triangles that could branch off of it. By branch I mean share two vertices with it, and be on the same plane. Basically a triforce-like shape, starting with just the center triangle. It sounds like I'm getting into some advanced linear algebra here, so I'm hoping there's some math routines somewhere to take care of it. =P And before you ask, yes this is for a good reason. The map editor I'm working with stores planes as three points, and in some cases I'd like to procedurally convert them to quads. Thanks in advance.

##### Share on other sites
If there is no adjacency information for the triangles, you have to iterate through the list of triangles to find those sharing a tuple of vertices. Maps are often regular, and hence you may have implicit adjacency information available, speeding up the searching significantly.

You can use the normals of the both triangles then to check whether they are (non-overlapping) co-planar. The normals are then to be computed as the normalized cross-product of the difference vectors of 2 pairs of the 3 vertices.

You can also interpret the one triangle as a co-ordinate basis, and then try to solve the unshared vertex of the 2nd triangle by using the basis. The both triangles are co-planar if solving is possible at all.

But I think implementing the former method (i.e. using normals) is easier, especially when some tolerance due to numerical inaccuracy is considered (and IMHO it should be considered).

##### Share on other sites
A really simple way:

pick two vertices v0 and v1 that form an edge of your triangle. v2 is the third vertex.

midpoint = (v0 + v1) / 2
d = v2 - midpoint
new vertex = midpoint - d

This will form a parallelogram.

You can repeat for the other 2 edges to get the other possible third vertices.

Seriously crazy hard linear algebra. Lucky for you I'm a genius that can do it though.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634088
• Total Posts
3015447
×