Search code examples
c++mathopenglcurvespline

smooth out corners of a 3-point line strip


I have a line strip defined by 3 points, each having an x and y coordinate.

I'm trying to smooth out the middle (point 2) corner as shown in the picture below:

enter image description here

the gray line is the original line strip and the black one is the smoothed-out one. The smoothed out area should be constant across multiple values (as in it is not dependent on length of the line between p1 and p2 or p2 and p3).

I've originally been using bezier curves and a simple spline, however that did not do the trick since the smooth curve was obviously not same across multiple values.

How can I do this?


Solution

  • Pick 2 points on each line that are the same distance to the corner. On those points draw two lines at right angles to the lines you already have (normal vectors pointing bottom left). They will cross at a point which will be the center of a circle, part this circle will then be the smoothed corner.

    Rounded corner