Bezier curves

Bezier curves

Linear interpolation

Overview

Linear interpolation is of the form P(t), where a line is formed between the points P_0 and P_1 where t is time. The maximum number that t can be is 1 and therefore P(1) = P_1. In otherwords if t is at its maximum value then the interpolation is at the end point which is P_1. Following this logic, the midpoint between p_0 and p_1 is P(0.5) and so it should be defined that P(t) maps to coordinates mapping to ratios of the line-segment between P_0 and P_1 ~ with the ratio: t:1.

Applications to Bezier curves

Bezier Curves are formed in the interpolation of two interpolations or points. There is a line strip L_s, with the vertices V such that |V| = |L_s|+1.

Linear

In the case that |L_s| = 1, the equation interpolates two points and is linear

Quadratic

In the case that it is 2, it interpolates two linear interpolations and is quadratic.

Cubic

In the case that it is 3, it interpolates two quadratic interpolations and is cubic.

Quartic

In the case that it is 4, it interpolates two cubic interpolations and is quartic.

Formulae

Maths
p(t) = (1 - t)p_0 + tx_1, p(t) = (1 - t)p_0 + tp_1, p(t)
C
struct Vertex2{ float x; float y; }; void Vertex2_add(Vertex2* a, const Vertex2* b, const Vertex2* c){ a->x=b->x+c->x; a->y=b->y+c->y; }; void Vertex2_mul_by_double(Vertex2* a, const Vertex2* b, const double* c){ a->x=b->x*(*c); a->y=b->y*(*c); }; void linear_interpolation(Vertex2* a, const Vertex2* b, const Vertex2* c, const double* t){ Vertex2* h = new Vertex2{0, 0}; Vertex2* i = new Vertex2{0, 0}; double i_1; double i_2; i_1 = 1-(*t); Vertex2_mul_by_double(h, b, &i_1); Vertex2_mul_by_double(i, c, t); Vertex2_add(a, h, i); delete h; delete i; }