function createRegularPolygon(sides, angle) {
  return function (coordinates, geometry, projection) {
    const center = fromUserCoordinate(
      /** @type {LineCoordType} */ (coordinates)[0],
      projection,
    );
    const end = fromUserCoordinate(
      /** @type {LineCoordType} */ (coordinates)[coordinates.length - 1],
      projection,
    );
    const radius = Math.sqrt(squaredCoordinateDistance(center, end));
    geometry = geometry || fromCircle(new Circle(center), sides);

    let internalAngle = angle;
    if (!angle && angle !== 0) {
      const x = end[0] - center[0];
      const y = end[1] - center[1];
      internalAngle = Math.atan2(y, x);
    }
    makeRegular(
      /** @type {Polygon} */ (geometry),
      center,
      radius,
      internalAngle,
    );

    const userProjection = getUserProjection();
    if (userProjection) {
      geometry.transform(projection, userProjection);
    }
    return geometry;
  };
}
Create a `geometryFunction` for `type: 'Circle'` that will create a regular
polygon with a user specified number of sides and start angle instead of a
{@link import("../geom/Circle.js").Circle} geometry.
@param {number} [sides] Number of sides of the regular polygon.
    Default is 32.
@param {number} [angle] Angle of the first point in counter-clockwise
    radians. 0 means East.
    Default is the angle defined by the heading from the center of the
    regular polygon to the current pointer position.
@return {GeometryFunction} Function that draws a polygon.
@api