[Math] maximum of a 5th order bezier curve with restrictions

algebraic-curvesalgebraic-geometrybezier-curve

Say you have a Bézier Curve of the 5th order with restrictions on the Control points:

  • P0 & P1 are on a horizontal line
  • P2 & P3 are on a horizontal line
  • P4 & P5 are on a horizontal line
  • P1 & P2 are on a vertical line
  • P3 & P4 are on a vertical line

enter image description here

As you may know, a Bézier curve is a parametric curve, so it's a bit like plotting 1 curve against another curve, and looking at the 2-D projection.

Now my question is: in this specific situation, can I use a property (maximum/minimum/turning point/inflection point) of the X & Y variable of the Bézier curve to create a rule that will always give me the maximum/minimum of the blue 5th order Bézier curve? I mean in an analytic, non-iterative way.

enter image description here

In this case, the maximum is the red dot (I took the X-value for the maximum of the Y-variable of the Bézier) on the blue curve and the red dotted lines in the 2 plots above. But that is not always true.

In case you are interested, here is the R-code for the plots:

cpx<-c(0,10,10,20,20,30)
cpy<-c(5,5,40,40,-50,-50)
t<-seq(0,1,len=101)
P0<-matrix(data=c(cpx[1],cpy[1]),nrow=1,ncol=2,byrow=FALSE,dimnames=NULL)
P1<-matrix(data=c(cpx[2],cpy[2]),nrow=1,ncol=2,byrow=FALSE,dimnames=NULL)
P2<-matrix(data=c(cpx[3],cpy[3]),nrow=1,ncol=2,byrow=FALSE,dimnames=NULL)
P3<-matrix(data=c(cpx[4],cpy[4]),nrow=1,ncol=2,byrow=FALSE,dimnames=NULL)
P4<-matrix(data=c(cpx[5],cpy[5]),nrow=1,ncol=2,byrow=FALSE,dimnames=NULL)
P5<-matrix(data=c(cpx[6],cpy[6]),nrow=1,ncol=2,byrow=FALSE,dimnames=NULL)
# 
# 
par(mfrow=c(1,1),mar=c(2,2,2,0))
B<-(1-t)^5%*%P0+5*((1-t)^4)*t%*%P1+10*t^2*(1-t)^3%*%P2+10*(1-t)^2*t^3%*%P3+5*(1-t)*t^4%*%P4+t^5%*%P5
plot(0,col="red",pch=20,type="n",xlim=c((min(cpx)-10),(max(cpx)+10)),ylim=c((min(cpy)-5),(max(cpy)+5)),main="Bézier Curve of 5th order")
lines(B,col='deepskyblue',lwd=3)
points(P0,pch=20)
points(P1,pch=20)
points(P2,pch=20)
points(P3,pch=20)
points(P4,pch=20)
points(P5,pch=20)
text(cpx[1],cpy[1],"P0",cex=.8,pos=2);text(cpx[2],cpy[2],"P1",cex=.8,pos=1);text(cpx[3],cpy[3],"P2",cex=.8,pos=2);text(cpx[4],cpy[4],"P3",cex=.8,pos=4);text(cpx[5],cpy[5],"P4",cex=.8,pos=4);text(cpx[6],cpy[6],"P5",cex=.8,pos=4)
segments(cpx[1],cpy[1],cpx[2],cpy[2],lty=3);segments(cpx[2],cpy[2],cpx[3],cpy[3],lty=3);segments(cpx[3],cpy[3],cpx[4],cpy[4],lty=3);segments(cpx[4],cpy[4],cpx[5],cpy[5],lty=3);segments(cpx[5],cpy[5],cpx[6],cpy[6],lty=3);
abline(h=0,lty=3);abline(v=0,lty=3)
# X-axis value of turning point:
tpx<-round(B[,1][B[,2]==max(B[,2])],1)

# turning point:
points(tpx,max(B[,2]),pch=20,col="red");abline(v=tpx,col='red',lty=3);abline(h=max(B[,2]),col='red',lty=3)

par(mfrow=c(2,1))
plot(B[,1],type="l",main="X-variable");abline(v=40,lty=3,col='red')
plot(B[,2],type="l",main="Y-variable");abline(v=40,lty=3,col='red')

Best Answer

I'm not 100% sure what you're asking, but I think you're interested in finding the maximum extents of the curve in the $y$-direction. If so, you can certainly do this analytically, without any iterative calculations.

Suppose we let $$ a = \text{the y-coordinate of } P_0 \text{ and } P_1 $$ $$ b = \text{the y-coordinate of } P_2 \text{ and } P_3 $$ $$ c = \text{the y-coordinate of } P_4 \text{ and } P_5 $$

Then the equation of the $y$-coordinate of the curve is $$ y(t) = a(1-t)^5 + 5at(1-t)^4 + 10bt^2(1-t)^3 + 10bt^3(1-t)^2 + 5ct^4(1-t) + ct^5 $$ Differentiating and simplifying, we get $$ y'(t) = 20t(t-1)\left[ (a-c)t^2 +2(b-a)t +a - b\right] $$ The maximum you seek occurs where $y'(t)=0$, of course. From above, we can see that this happens when $t=0$, or when $t=1$, or when $t$ is a root of the quadratic inside the square brackets. So, the real key to finding the maximum is finding the roots of the quadratic, which I expect you know how to do. Then you have to do the usual tests on the sign of $y''$ to figure out which roots correspond to maxima and which are minima.

Note that we have made no use of the $x$-coordinates of the control points -- they are irrelevant.

Related Question