Pomax / BezierInfo-2

The development repo for the Primer on Bézier curves, https://pomax.github.io/bezierinfo
https://pomax.github.io/bezierinfo
Other
2.35k stars 289 forks source link

just use `z` instead of `0 + z * t` in section 11. #389

Open Pomax opened 11 months ago

Pomax commented 11 months ago

It's more confusing than useful.

Haiderahandali commented 11 months ago

Here is my logic behind it We have our range of t as follows: 0 <= t<= 1 We want to split it (let's say at t =1/3) such that, As t varies from 0 to 1, our Our range varies from 0 to to 1/3 (the original way I did it is multiplying the range above by value z, so our range becomes: 0 <= t*z <= z, which is exactly what we wanted, but I knew this would not work for the second case, because if wanted to start from z and not 0, we have to shift our entire range by z so it becomes z <= t+z <= 1+z But this is wrong because at t = 1 our range is 1+z, so we have to multiply t by some constant ( say c) such that z + ct=1 So at t = 1, c =1-z So as t varies from 0 to 1 z+t(1-z) varies from z to 1)

Below is a more systematic way of arriving at the same result.

So we have to replace t by the simplest possible equation, the linear equation! a + bt, for some constants a and b. (actually it's affine but everyone calls it linear) We want to start from t=0 our range starts at 0, so we have a + bt = 0 (at t =0) a + 0*b=0 Then a = 0 We want at t = 1, our range becomes 1/3 So we have a + bt = 1/3 Sub a = 0, t =1 Then our equation becomes instead of t, we have 1/3t.

So now, in order to split the original range from 0 to 1 we replace t by t*z and we get our range to vary from 0 to z.

In the exact same manner if we split at value z, and want to transform our range from 0 to 1 into a new range from z to 1 We have: a +bt. At t = 0 we want to start at value z, a + bt = z Sub t = 0 a +b 0= z, then a = z At t = 1, we want our range to be 1: a + bt = 1 Sub a=z, t=1 z = 1b = 1 b = 1-z Then to map our range from (originally from 0 to 1) into z to 1 we replace t by z + (1-z)t

That is why we replace t by t*z in our first range And t by z+t(1-z) In the second range I hope it made sense.