BezierInfo-2 icon indicating copy to clipboard operation
BezierInfo-2 copied to clipboard

Choosing `e1` and `e2`

Open luc4leone opened this issue 3 years ago • 8 comments

Section 31

There are again all kinds of approaches we can take, and a simple-but-effective one is to set the length of that segment to "one third the length of the baseline"

  1. What's the baseline?
  2. Why is it a good approach?

This forces e1 and e2 to always be the "linear curve" distance apart, which means if we place our three points on a line, it will actually look like a line.

Totally lost here :) @Pomax can you please elaborate more or in a different way?

luc4leone avatar Aug 31 '21 15:08 luc4leone

The base line is the line between start and end.

As for (2) and the followup question: draw it out to understand it. Take a cubic curve, place all its control points on a line, equally spaced, so for instance start=(0,0), c1=(1,0), c2=(2,0), end=(3,0). This is still a Bezier curve, but it draws a line. Now, compute and draw points for t=0, t=1/3, t=2/3, and t=1 on that curve: what's special about their where they ended up?

(or use the sketch in https://pomax.github.io/bezierinfo/#splitting with the points four grid spaces apart each, if you don't want to draw it by hand, of course)

Pomax avatar Aug 31 '21 17:08 Pomax

what's special about their where they ended up?

I am not sure I get it. What I see is that they stay on the line and that they are always 4 grid space apart. Is that what I should have come to? Still don't understand why setting e2-e1 == "one third the length of the baseline" is a good approach. Still need your help 😉

t = 0

image

t = 1/3

image

t == 2/3

image

t = 1

image

luc4leone avatar Sep 01 '21 16:09 luc4leone

Good start, now, do the same thing but move the control points up one grid spot, so you can see the construction skeleton, and set t to 0.5. Now what do you notice about where e1 and e2 are?

Pomax avatar Sep 01 '21 16:09 Pomax

image

Now what do you notice about where e1 and e2 are?

That they are on the same x of the control points? And that they are still 1/3 of the baseline away, comparing to when all the control points were in the same line.

luc4leone avatar Sep 02 '21 07:09 luc4leone

right, so now we know why "one third of the baseline" is at least a good approach: it matches how cubic curves already work, and we see that in the "linear" curve, where e1 is the same coordinate as C1, and e2 is also the same coordinate as C2.

Pomax avatar Sep 03 '21 00:09 Pomax

more clear now @Pomax thanks, but not totally. Maybe by compare & contrast I'll get it. Can you please give me an example of another reasonable approach to choose the length of the segment e2-e1; instead of "1/3 of the baseline" what would be another good one?

luc4leone avatar Sep 03 '21 05:09 luc4leone

I can't because it depends entirely on your own aesthetic choices and the needs of your users, and what you consider "a good looking curve". You work backwards: you have three points, what curve would you draw through that? Cool, now what cubic curve parameters go with that?

The 1/3rd length is merely the simplest, basic-curve-property-associated approach that yields reasonable curves, but maybe you want e1/e2 to change depending on the distance and angle of B with respect to start/end, there are as many ways to come up with e1/e2 as there are curves to fit through three points, so it really is a matter of "this is the part that is up to you".

Pomax avatar Sep 04 '21 15:09 Pomax

ok, got it. I'll so some experiments, thanks!

luc4leone avatar Sep 06 '21 17:09 luc4leone