A cubic curve is defined by point (1,1);(2,3);(4,4) and (6,1) cal the parametric mid point of the curve and verify that its gradient dy/dx is 1/7 at this point
I successfully calculate the mid point by using the parametric value as 0.5 in my cubic parametric equation i finally got the mid point value as (3.1,2.8)
How do i verify the gradient dy/dx at that midpoint which 1/7
any cubic curve is defined as:
where
a0,a1,a2,a3are coefficients (vectors) computed from control pointsp0,p1,p2,p3(vectors) andtis (scalar) parameter on interval<0.0,1.0>for cubic Bezier its:Now the gradient of
p(t)is equal to 1st derivationp'(t)by parametertso:so simply given any parameter
tin 2D your gradient (slope) would be:In case you have access to
p(t)and do not want to computea0,a1,a2,a3You can do numericall derivation ofp(t)like this:where
epsilonis some small value (like0.001beware too big value will lower precision and too small will lead to zero result) So:Now using both methods with:
t=0.5, epsilon=0.001, p0(1,1), p1(2,3), p2(4,4), p3(6,1)lead to:Note that algebraic approach is safe (an should be more precise) and numeric depends on correct setting of epsilon value...