0

I am working with a program that defines its Curves with 'Edges' that have three control points (The red points 0, 1, 2 in the attached image). I believe this is a Quadratic Curve.

This is a list of their x & y coordinates: [(736,620), (963, 488), (1200, 620)]. Point 1 determines the curvature of the 'Edge.'

I am trying to derive a Cubic Curve from this Quadratic Curve, then getting the X & Y of Handle 1 & 2. How may I go about this? Thank you.

Control Points

  • Quadratic curves don't have "handles", they have a single control point that's located at the intersection of the tangents at the start and end point. You're thinking of cubic curves, which have two control points, forming "handles" with their respective on-curve points. You can [trivially uplift](https://pomax.github.io/bezierinfo/#reordering) a quadratic curve to a cubic curve, but it doesn't sound like that's what you actually want? – Mike 'Pomax' Kamermans May 09 '23 at 18:30
  • @Mike'Pomax'Kamermans Thank you for the reply. I've edited my question with your feedback. – Dr. Pontchartrain May 09 '23 at 18:34
  • @Mike'Pomax'Kamermans It should be there now. I was editing the question. Please let me know if I have this correct. – Dr. Pontchartrain May 09 '23 at 18:37
  • In that case: see link. You have your three quadratic points, you can directly calculate the equivalent cubic four points (of which the start and end stay the same of course). The second paragraph quite literally explains that specific use case, and the rest of the section covers the general case =) – Mike 'Pomax' Kamermans May 09 '23 at 18:38
  • @Mike'Pomax'Kamermans, my apologies, the math formulas in the linked page wouldn't be a trivial matter for me with where I am math skill-wise. I will try to recreate this curve in Javascript to get a better understanding of the quadratic curve to cubic curve in code. Thank you for your guidance. – Dr. Pontchartrain May 09 '23 at 18:41
  • Like I said, the second paragraph explains it, in plain text, specifically for this case. You don't need to read anything beyond that because you don't care about the general case. The first two paragraphs are perfectly understandable to anyone who can read English =) – Mike 'Pomax' Kamermans May 09 '23 at 18:42
  • @Mike'Pomax'Kamermans I got this formula before, using ChatGPT. The handles' locations were not correct for my purposes (as in they didn't match those in my vector graphic application): Handle Control Point 1 = (2/3) * P0 + (1/3) * P1 Handle Control Point 2 = (2/3) * P2 + (1/3) * P1 – Dr. Pontchartrain May 09 '23 at 18:43
  • **ChatGPT will tell as many lies as it needs to in order to generate the story you asked it to generate**. That's its whole thing, so I don't care what ChatGPT says, nor should you. Now, I wrote that book I linked you to, and that second paragraph tells you how you do what you're asking about doing =) – Mike 'Pomax' Kamermans May 09 '23 at 18:44
  • @Mike'Pomax'Kamermans Thank you for the response. Are the formulas incorrect? – Dr. Pontchartrain May 09 '23 at 18:46
  • Yes, they are wrong. And if you read that paragraph, you will see how they differ from the real solution. – Mike 'Pomax' Kamermans May 09 '23 at 18:46
  • @Mike'Pomax'Kamermans, I'm not understanding how to create the code from the second paragraph logic. I'm also happy to do research on how to convert, but if you know how I can do this code-wise, I'd be very grateful. – Dr. Pontchartrain May 09 '23 at 18:47
  • Can you explain where in "_we give it the same start and end points, and for its two control points we pick 1/3rd start + 2/3rd control and 2/3rd control + 1/3rd end_" are you getting lost? Because that's already the programming explanation for getting the two cubic control points, just written in plain text. – Mike 'Pomax' Kamermans May 09 '23 at 18:49
  • My apologies, Mike. 1/3 start, 1/3 end - does this mean multiplying the start & end's control points' x & y coordinates by 0.333? And the controls' x & y by 0.666? – Dr. Pontchartrain May 09 '23 at 18:51
  • 1
    Correct, that is what it means. – Mike 'Pomax' Kamermans May 09 '23 at 18:53
  • @Mike'Pomax'Kamermans Excellent, thank you. I was thinking it might mean the distances between the control points or traveling along the curve. I'll try this and add to this question. I'm very grateful for the help!! – Dr. Pontchartrain May 09 '23 at 18:54
  • @Mike'Pomax'Kamermans I think I worked this out in Python: https://trinket.io/python3/963ba59af3 Thank you again, for your help. – Dr. Pontchartrain May 09 '23 at 19:34
  • 1
    Looks good to me. A small note though: they are *both* Bezier curves, one's a quadratic curve, the other a cubic curve. Calling one "Quadratic" and the other "Bezier" is like showing a picture of an apple and an orange, but labelling them "Apple" and "Fruit" respectively =P – Mike 'Pomax' Kamermans May 09 '23 at 21:14
  • Note that I’m voting to close this question because chatgpt gave the wrong information, and looking up and implementing the correct information worked just fine, so there isn't much reason for this question to stick around, it was basically solved by "consulting a reputable source" instead of chatgpt =) – Mike 'Pomax' Kamermans May 10 '23 at 15:00

0 Answers0