Arc length of a Quadratic Bezier

A quadratic bezier is expressed as follows, where A, B and C are our control points. We'll assume these are 2d vectors. t represents how far along the curve we are. g(t)=A(1t)2+2B(1t)t+Ct2,tϵ[0,1] \textbf{g(}t\textbf{)} = A (1 - t)^2 + 2 B (1 - t) t + C t^2, t \epsilon [0, 1]

The arc length of any curve can be expressed as follows δx2+δy2 \int \sqrt{\delta x^2 + \delta y^2} We can think of g(t)g'(t) as follows δxδt=gx(t),δyδt=gy(t) \dfrac{\delta x}{\delta t} = g'_{x}(t), \dfrac{\delta y}{\delta t} = g'_{y}(t) Therefore δx2+δy2=δx2δt2+δy2δt2δt=(gx(t))2+(gy(t))2δt=g(t)δt \int \sqrt{\delta x^2 + \delta y^2} = \int \sqrt{\dfrac{\delta x^2}{\delta t^2} + \dfrac{\delta y^2}{\delta t^2}} \delta t = \int \sqrt{(g_{x}'(t))^2 + (g_{y}'(t))^2} \delta t = \int ||g'(t)|| \delta t

We need to find g(t)2||g'(t)||^2 g(t)=2[(A2B+C)t+(BA)] g'(t) = 2[(A-2B+C)t + (B - A)] Therefore g(t)2=4(A2B+C2t2+(A2B+C)(BA)t+BA2) ||g'(t)||^2 = 4(||A - 2B + C||^2 t^2 + (A - 2B + C)\cdot(B - A)t + ||B - A||^2)

This leavs us with a root of a quadratic polynomial in the following form. a=4A2B+C2,b=4(A2B+C)(BA),c=4BA2g(t)δt=at2+bt+cδt a = 4||A - 2B + C||^2, b = 4(A - 2B + C)\cdot(B - A), c = 4||B - A||^2 \\ \int ||g'(t)|| \delta t = \int \sqrt{a t^2 + b t + c} \delta t Dividing by "a" and converting to a depressed qradratic we get m=ba,n=ca,at2+mt+nδt=a(m2+t)2+nm24δt m = \dfrac{b}{a}, n = \dfrac{c}{a}, \sqrt{a} \int \sqrt{t^2 + m t + n} \delta t = \sqrt{a} \int \sqrt{(\dfrac{m}{2} + t)^2 + n - \dfrac{m^2}{4}} \delta t We do some u sub giving us a quadratic in the following form k=nm24,u=m2+t,δu=δt,au2+kδu k = n - \dfrac{m^2}{4}, u=\dfrac{m}{2}+t, \delta u = \delta t, \sqrt a \int \sqrt{u^2 + k} \delta u For this to work we need to ensure that k is positibe or we're going to have a bad day. We'll assume A, B and C are scaler in this example for simplicity even though they're not. p=(A2B+C),q=(BC)a=p2,b=pq,c=q2k=cab24a2=q2p2p2q24p4=q2p2q24p2q2p2>q24p2 p = (A - 2B + C), q = (B - C) \\ a = p^2, b = p q, c = q^2 \\ k = \dfrac{c}{a} - \dfrac{b^2}{4a^2} = \dfrac{q^2}{p^2} - \dfrac{p^2q^2}{4p^4} = \dfrac{q^2}{p^2} - \dfrac{q^2}{4p^2} \\ \dfrac{q^2}{p^2} > \dfrac{q^2}{4p^2} This proves k is positive. Going back to our integral, we then divide our integral by k\sqrt k. ak(uk)2+1δu \sqrt {a k} \int \sqrt{(\dfrac{u}{\sqrt k} )^2 + 1} \delta u More u sub v=uk,δv=δuk,kav2+1δv v = \dfrac{u}{\sqrt k}, \delta v = \dfrac{\delta u}{\sqrt k}, k \sqrt a \int \sqrt{v^2 + 1} \delta v Now we can subsitute v=tan(Θ)v = tan(\Theta) δv=sec2(Θ)δΘ,katan2(Θ)+1sec2(Θ)δΘ=kasec2(Θ)sec2(Θ)δΘ=kasec3(Θ)δΘ \delta v = sec^2(\Theta) \delta \Theta, k \sqrt a \int \sqrt{tan^2(\Theta) + 1} sec^2(\Theta) \delta \Theta \\ = k \sqrt a \int \sqrt{sec^2(\Theta)} sec^2(\Theta) \delta \Theta \\ = k \sqrt a \int sec^3(\Theta) \delta \Theta Now do integration by parts sec3(Θ)δΘ=sec2(Θ)sec(Θ)δΘ=sec(Θ)tan(Θ)tan2(Θ)sec(Θ)δΘ=sec(Θ)tan(Θ)sec3(Θ)sec(Θ)δΘ \int sec^3(\Theta) \delta \Theta = \int sec^2(\Theta) sec(\Theta) \delta \Theta \\= sec(\Theta) tan(\Theta) - \int tan^2(\Theta) sec(\Theta) \delta \Theta \\= sec(\Theta) tan(\Theta) - \int sec^3(\Theta) - sec(\Theta) \delta \Theta Now add sec3(Θ)δΘ\int sec^3(\Theta) \delta \Theta to both sides 2sec3(Θ)δΘ=sec(Θ)tan(Θ)+sec(Θ)δΘ 2 \int sec^3(\Theta) \delta \Theta = sec(\Theta) tan(\Theta) + \int sec(\Theta) \delta \Theta Integrating we get sec3(Θ)δΘ=12sec(Θ)tan(Θ)+12lnsec(Θ)+tan(Θ) \int sec^3(\Theta) \delta \Theta = \frac{1}{2} sec(\Theta) tan(\Theta) + \frac{1}{2}ln|sec(\Theta) + tan(\Theta)| Now substituting in sec2=tan2+1sec^2 = tan^2 + 1 we get sec3(Θ)δΘ=12tan(Θ)1+tan2(Θ)+12ln1+tan2(Θ)+tan(Θ) \int sec^3(\Theta)\delta\Theta = \frac{1}{2} tan(\Theta) \sqrt{1 + tan^2(\Theta)} + \frac{1}{2} ln|\sqrt{1 + tan^2(\Theta)} + tan(\Theta)| Now substituting in v=tan(x)v = tan(x) and adding our kak\sqrt a back we get the following. kav2+1δv=ka2[v1+v2+ln(1+v2+v)] k\sqrt a \int \sqrt{v^2 + 1}\delta v = \frac{k\sqrt a}{2} [v \sqrt{1+v^2} + ln(\sqrt{1+v^2} + v)] Finally we need to calculate v and k in terms of A, B, C and t. I might also multipley my integral by two then divide a b and c by four. P=(A2B+C),Q=(BC) P = (A - 2B + C), Q = (B - C) a=PP,b=PQ,c=QQ,k=3c4a,z=b2ak,v=z+tk a = P \cdot P, b = P \cdot Q, c = Q \cdot Q, k = \dfrac{3 c}{4 a}, z = \dfrac{b}{2a\sqrt k}, v = z + \dfrac{t}{\sqrt k} arclength=ka(v1+v2+ln(1+v2+v)z1+z2+ln(1+z2+z)) arclength = k\sqrt a (v \sqrt{1+v^2} + ln(\sqrt{1+v^2} + v) - z \sqrt{1+z^2} + ln(\sqrt{1+z^2} + z) ) And we're done