I am trying to compute a polygon that surrounds a line connecting multiple points (e.g. GPX track). The figure below shows an example with a track as a red line, and the desired polygon - blue.

As a simplification, red dots are denoted by x and y - not in latitude / longitude.
How to calculate such an environment (blue polygon) if I have only a list of three points indicating the path?
Partial solutions (for example, for only two points) or hints about math libraries (in Java) that provide algorithms for such a calculation will also take me one step further.
Further assumptions:
Update: Using the approach presented by Rogach and Ksan, I ran into some problems if the angle between the lines is less than 90 degrees or more than 270 degrees:
As you can see, the polygon falls into itself, which leads to a serious problem.
From my point of view, using java.awt.geom.Area is the best approach:
My solution (based on Rogach code):
For each line connecting the two points of the track, I compute the surrounding polygon. Subsequently, I add (area union) the computed polygon to the area that does all the necessary calculations for me. Since Area strictly uses the “or” algorithm when adding new polygons, I don’t have to worry about the “self-intersections” of the polygon, as shown in the update above.

Area area = new Area(); for (int i = 1; i < points.size(); i++) { Point2D point1 = points.get(i - 1); Point2D point2 = points.get(i); Line2D.Double ln = new Line2D.Double(point1.getX(), point1.getY(), point2.getX(), point2.getY()); double indent = 15.0; // distance from central line double length = ln.getP1().distance(ln.getP2()); double dx_li = (ln.getX2() - ln.getX1()) / length * indent; double dy_li = (ln.getY2() - ln.getY1()) / length * indent; // moved p1 point double p1X = ln.getX1() - dx_li; double p1Y = ln.getY1() - dy_li; // line moved to the left double lX1 = ln.getX1() - dy_li; double lY1 = ln.getY1() + dx_li; double lX2 = ln.getX2() - dy_li; double lY2 = ln.getY2() + dx_li; // moved p2 point double p2X = ln.getX2() + dx_li; double p2Y = ln.getY2() + dy_li; // line moved to the right double rX1_ = ln.getX1() + dy_li; double rY1 = ln.getY1() - dx_li; double rX2 = ln.getX2() + dy_li; double rY2 = ln.getY2() - dx_li; Path2D p = new Path2D.Double(); p.moveTo(lX1, lY1); p.lineTo(lX2, lY2); p.lineTo(p2X, p2Y); p.lineTo(rX2, rY2); p.lineTo(rX1_, rY1); p.lineTo(p1X, p1Y); p.lineTo(lX1, lY1); area.add(new Area(p)); }