Class BezierShapeGenerator

java.lang.Object
micycle.pgs.commons.BezierShapeGenerator

public class BezierShapeGenerator extends Object
2D random shape generator using Bezier curves.
Author:
Michael Carleton, Jonathan Viquerat
  • Constructor Summary

    Constructors
    Constructor
    Description
    BezierShapeGenerator(int nControlPts, double bezierSampleDistance, double radius, double spikiness)
    Constructs a BezierShapeGenerator object with the specified number of control points, bezier sample distance, radius and spikiness.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.locationtech.jts.geom.Coordinate[]
    generate(boolean centering, boolean cylinder, double scale, long seed)
    Generates a shape's curve based on the control points.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BezierShapeGenerator

      public BezierShapeGenerator(int nControlPts, double bezierSampleDistance, double radius, double spikiness)
      Constructs a BezierShapeGenerator object with the specified number of control points, bezier sample distance, radius and spikiness.
      Parameters:
      nControlPts - The number of control points for the bezier curve.
      bezierSampleDistance - The sample distance along the bezier curve.
      radius - The radius relative to the distance between adjacent points. The radius is used to position the control points of the bezier curve, should be between 0 and 1. Larger values result in sharper features on the curve.
      spikiness - A measure of the curve's smoothness. If 0, the curve's angle through each point will be the average between the direction to adjacent points. As it increases, the angle will be determined mostly by one adjacent point, making the curve more "spiky".
  • Method Details

    • generate

      public org.locationtech.jts.geom.Coordinate[] generate(boolean centering, boolean cylinder, double scale, long seed)
      Generates a shape's curve based on the control points. The shape's curve can be scaled, centered and sorted in counter-clockwise order.
      Parameters:
      centering - If true, the generated shape will be centered at the origin (0, 0).
      cylinder - If true, the control points will be initialized in a cylindrical formation. If false, the control points are generated randomly.
      scale - The factor by which the initial control points are magnified.
      seed - The seed used for random control point generation (applicable when cylinder is false).
      Returns:
      An array of Coordinates representing the generated shape's vertices.