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

Quadratic Bezier Curves #203

Open
MaxDeVos opened this issue Apr 25, 2024 · 1 comment
Open

Quadratic Bezier Curves #203

MaxDeVos opened this issue Apr 25, 2024 · 1 comment

Comments

@MaxDeVos
Copy link

Disclaimer: I feel as though I am missing something fundamental here, that some existing component already serves this purpose and I don't know it.

Is there a reason that quadratic Bezier curves are not explicitly supported by this library? The BezierCurve2 class explicitly excludes them, likely due to not having a valid result for GetThirdDerivative(double t). I see three potential solutions to this:

  1. BezierCurve2 is modified to automatically convert quadratic bezier curves to cubic ones by calculating control point 1, which can be done as follows:
$$\begin{align*} C_0 &= Q_0 \\\ C_1 &= Q_0 + \frac{2}{3}(Q_1-Q_0) \\\ C_2 &= Q_2 + \frac{2}{3}(Q_1-Q_2) \\\ C_3 &= Q_2 \end{align*}$$
  1. QuadraticBezierCurve2 is added and its implementation of GetThirdDerivative(t) always returns double.NaN.
  2. BezierCurve2 is modified to natively support quadratic bezier curves, but the boolean property isQuadratic is added, and GetThirdDerivative(t) returns double.NaN when the curve is quadratic.
@rms80
Copy link
Contributor

rms80 commented Apr 25, 2024

The curve classes were added to support various projects I was working on at different times, and I guess I didn't have a need for quadratic Bezier curves. So that's why it's not supported. Your solutions seem plausible but I am not going to implement them, feel free to submit a PR.

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

2 participants