# How to calculate a quad based on a triangle pairs shared edge

Based on two given triangles, I would like to calculate a quad that can be used as a 'fat' line for the edge between the triangles.

I have googled around and while it is very easy to draw lines in OpenGL or DirectX, the problem is that you can only guarantee a thickness of 1 pixel.

To overcome this I need to generate a quad for the line.

So given the below image...

I have a set of triangles, and I want to draw a line where the red dots are. I know the start and end vectors for this line. And all the details of the triangles

I need to create a quad so that I can define the thickness (seen as the blue arrow)

An extra complication is that the triangles may not be on the same plane.

So from the side perspective, the 'line' would need to be created with its edge growing like this. Where both black lines are the sides of two separate tringles and the shared edge is from the point and moves into the screen.

All the calculation for this will be done offline

I am hoping that just a nudge in the right direction and I will be able to hammer this out on my own. (maybe)

OR if there is another way to solve the fat line problem then let me know. I will be rendering this using OpenGL ES 1 (without a shader)

Thanks.

Take the unit normal of each triangle, then normalize their sum. This gives you the normal of the plane of your quad, making an equal angle with each of its parent triangles.

Vector3 edgeNormal = Normalize(
edge.leftTriangle.normal
+ edge.rightTriangle.normal
);


Next take the vector from the start to the end of the edge you want to fatten. Cross it with the quad normal to get a perpendicular vector in the quad plane, and normalize this too.

Vector3 edgeVector = edge.endPoint
- edge.startPoint;

Vector3 perpendicular = Normalize(
Cross(edgeNormal, edgeVector)
);


edge.startPoint ± 0.5 * thickness * perpendicular

• Somethibf like this: Vector3 edgeVector = edge.endPoint - edge.startPoint; This gives you a vector pointing along the edge, from the start point to the end point. – DMGregory Jul 25 '18 at 0:49