xdot/ui/elements.py
def _cubic_bernstein_extrema(p0, p1, p2, p3):
        """
        Find extremas of a function of real domain defined by evaluating
        a cubic bernstein polynomial of given bernstein coefficients.
        """
        # compute coefficients of derivative
        a = 3.*(p3-p0+3.*(p1-p2))
        b = 6.*(p0+p2-2.*p1)
        c = 3.*(p1-p0)

        if a == 0:
            if b == 0:
                return ()  # constant
            return (-c / b,)  # linear

        # quadratic
        # compute discriminant
        d = b*b - 4.*a*c
        if d < 0:
            return ()

        k = -2. * a
        if d == 0:
            return (b / k,)

        r = math.sqrt(d)
        return ((b + r) / k, (b - r) / k)
def _cubic_bernstein_extrema(p0, p1, p2, p3):
        # compute coefficients of derivative
        a = 3.*(p3-p0+3.*(p1-p2))
        b = 6.*(p0+p2-2.*p1)
        c = 3.*(p1-p0)

        if a == 0:
            if b == 0:
                return ()  # constant
            return (-c / b,)  # linear

        # quadratic
        # compute discriminant
        d = b*b - 4.*a*c
        if d < 0:
            return ()

        k = -2. * a
        if d == 0:
            return (b / k,)

        r = math.sqrt(d)
        return ((b + r) / k, (b - r) / k)
def _cubic_bernstein_extrema ( p0 , p1 , p2 , p3 ) : # compute coefficients of derivative a = 3. * ( p3 - p0 + 3. * ( p1 - p2 ) ) b = 6. * ( p0 + p2 - 2. * p1 ) c = 3. * ( p1 - p0 ) if a == 0 : if b == 0 : return ( ) # constant return ( - c / b , ) # linear # quadratic # compute discriminant d = b * b - 4. * a * c if d < 0 : return ( ) k = - 2. * a if d == 0 : return ( b / k , ) r = math . sqrt ( d ) return ( ( b + r ) / k , ( b - r ) / k )
Find extremas of a function of real domain defined by evaluating
        a cubic bernstein polynomial of given bernstein coefficients.
Find extremas of a function of real domain defined by evaluating a cubic bernstein polynomial of given bernstein coefficients .