# Revision history [back]

### how to get y component of bezier control points?

or is there a utility in sage that returns the bezier control points of a curve given that curve?

im writing a program that takes a curve in polynomial form and returns those control points, this is the part in question:

def bezierControlPoints(poly):
a = sage.var('a')
b = sage.var('b')
c = sage.var('c')
d = sage.var('d')
t = sage.var('t')
bezier = ((1 - t) ** 3) * a + 3 * ((1 - t) ** 2) * t * \
b + 3 * ((1 - t) * (t ** 2)) * c + (t ** 3) * d
eqn1 = poly.substitute(t=0)
eqn2 = poly.substitute(t=.33)
eqn3 = poly.substitute(t=.66)
eqn4 = poly.substitute(t=1)
cb1 = bezier.substitute(t=0)
cb2 = bezier.substitute(t=.33)
cb3 = bezier.substitute(t=.66)
cb4 = bezier.substitute(t=1)

solns = sage.solve([eqn1 == cb1, eqn2 == cb2, eqn3 == cb3,
eqn4 == cb4], a, b, c, d, solution_dict=True)
return [[s[a].n(30), s[b].n(30), s[c].n(30), s[d].n(30)] for s in solns]


but the control points are coordinates, and this returns single numbers like coefficients. for example

f(x) =  x^4 - 10*x^3 + 35*x^2 - 50*x + 24


returns

[24.000000, 3.8069265, -4.2949254, -0.30555556]

[-0.30555556, 0.85185185, 0.85185185, -0.30555556]

[-0.30555556, -1.3680046, -1.2661527, 0.00000000]


so how do i finish processing these portions of the control points?

background

the parts of the program i have written that i didnt share take the polynomial of arbitrary order, break it up into simpler subcurves, parameterize those subcurves, and those parameterized subcurves are the arguements of the bezierControlPoints(), which is called iteratively depending on the order of the polynomial.