Skip to content

Improvements to the Curve Javadoc #5

@richardTingle

Description

@richardTingle

I'm trying to add some javadoc comments to the Curve class (largely because I didn't understand how to use it so have started experimenting with it). Having had a play and a read up on Bézier curves I think this is correct

  /**
   * Adds a control point to the curve. The line will enter the control point with the following
   * rules but may curve between control points so a continuous line is formed.
   *
   * Note that if the implied gradient entering the control point is different from the implied gradient exiting it then
   * the gradient may sharply change (but the line itself will remain continuous).
   *
   * Between each pair of control points acts as an independent cubic Bézier curve defined by the following:
   *
   * anchor 1 - the 'point' of the first control point (the line will pass through this point)
   * intermediate point 1 - the 'out' of the first control point (the line may not go through this point but it controls the initial direction the line exits anchor 1)
   * intermediate point 2 - the 'in' of the second control point (the line may not go through this point but it controls the initial direction the line enters anchor 2)
   * anchor 2 - the 'point' of the second control point (the line will pass through this point)
   *
   * Instinctively you can think of each section "trying" to go from anchor 1 -> intermediate point 1 -> intermediate point 2 -> anchor 2
   * but being smoothed using a quadratic curve such that it may not actually touch the intermediate points.
   * 
   * Note; if this is the first control point the in doesn't matter and if its the last control point the out doesn't matter
   *
   * @param in
   *          the intermediate point immediately before this anchor point.
   *          This is a control point in Bézier curve terminology
   * @param point
   *          the line will pass through this point. This is an anchor point in Bézier curve terminology
   * @param out
   *          the intermediate point immediately after this anchor point.
   *          This is a control point in Bézier curve terminology
   * @return this curve
   */
  public Curve addControlPoint(Vector2f in, Vector2f point, Vector2f out) {

Slightly difficultly I think (according to my reading of Bézier_curves) the addControlPoint method actually adds 2 control points and an anchor, but I can see why the method is like that and I'm not sure I have any better suggestions.

Assuming that's correct I plan to put in a PR to improve the javadoc here as well as put a bit in SizeInfluencer as to how it can be used with a curve to produce a size change over time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions