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...

enter image description here

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.

enter image description here

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)



1 Answer 1


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.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)

The four corners of your quad are then:

edge.startPoint ± 0.5 * thickness * perpendicular
edge.endPoint ± 0.5 * thickness * perpendicular
  • \$\begingroup\$ Thanks, but i don't understand this bit "Next take the vector from the start to the end of the edge" how can you take a point from two points? \$\endgroup\$
    – Paul Spain
    Jul 25, 2018 at 0:15
  • \$\begingroup\$ 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. \$\endgroup\$
    – DMGregory
    Jul 25, 2018 at 0:49
  • \$\begingroup\$ thanks, that's what I was guessing,, Just writing it now. Thanks for the help \$\endgroup\$
    – Paul Spain
    Jul 25, 2018 at 0:59
  • \$\begingroup\$ All works, thanks very much. Only surprise was that thickness needed to be quite a small number (0.2) for me. \$\endgroup\$
    – Paul Spain
    Jul 25, 2018 at 2:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .