While reading a book which explain different type of curves I couldn't see any description about qudratic curves( eventhough it is a good book) . Hence i decided to solve it by myself. That is what is shown below. :) . If you are looking for a simple curve this may be suffient . Qudratic curve offers only one control point (tangent)to control the shpae.
The simple Quadratic equation can be used to connect two point in space by a curve. The qudratic equation is simple and has the generic form at^2 + bt + C. Where a ,b,c can be any suitable quantity. Here i am taking it as a vector , and t is time( or any scalar).
we have two points in space , p0 and p1 , we want to draw a curve to connect these two points. So the question may arise how to control the curve position/direction. Okay , So you may be waiting for that third parameter .
So what is said earlier is f(t) = at^2 + bt + c. -------- (1)While interpolating what we need is f(0) should give p0 (starting point) and f(1) should give p1 (end point).
f(0) = p0 and f(1) = p1.
Thus putting 0 in equation (1) gives f(0) -> c = p0.and 1 in equation (1) gives f(1) -> a+b+c = p1 --------(2)
If we differentiate the equation (1) we will get 2at + b . As before we are assuming when t= 0 output is p0'
ie f '(0) = p0' , which is 2a* 0 + b = p0' , thus we will get b = p0'So just now we have solved two unknowns b and c,which is equal to p0' and p0 respectievly.
substituting b and c in Equation (2) gives
a+ p0' + p0 = p1 , So a = p1 - p0' - p0Holy cow! You just solved that equation , now you can smoothly interpoltate it by changing the paramter "t".
The final equation becomes t^2(p1-p0'-p0) + p0' * t + p0 .
At t = 0 it will give p0 and at t=1 it will give p1 as output. You can change p0' to change the shape of the curve. p0' is a vector , if its direction is same as p1-p0 vector the result will be straight line connectin p0 and p1 . Try changing t and p0' to get the desired results.
The below picture shows the curve drawn by this technique... The picture is unclear actually curve is smooth ( i don't know how to correct it ).