Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to the Curve Javadoc #5

Open
richardTingle opened this issue Dec 17, 2021 · 1 comment
Open

Improvements to the Curve Javadoc #5

richardTingle opened this issue Dec 17, 2021 · 1 comment

Comments

@richardTingle
Copy link
Contributor

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

richardTingle added a commit to richardTingle/particlemonkey that referenced this issue Dec 18, 2021
richardTingle added a commit to richardTingle/particlemonkey that referenced this issue Dec 18, 2021
@richardTingle
Copy link
Contributor Author

I now realise, looking more closely at the code, that the X of in and out doesn't actually matter. Is that intentional. I think I can see that the original intention was that it would matter but because the x and t are being treated as the same thing the X of the control points ends up meaningless.

I think I probably could fix that and make it a true Bezier curve (all be it one that requires that the X of each point is equal to or larger that the previous point to avoid any "the line goes backwards in time" nonsense). That change though would mean the curves would change a little for existing users

richardTingle added a commit to richardTingle/particlemonkey that referenced this issue Dec 19, 2021
…t; that the X of the control points currently do nothing, but should
richardTingle added a commit to richardTingle/particlemonkey that referenced this issue Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant