Ejemplo n.º 1
0
def default_color_function(z):
    if isinf(z):
        return (1.0, 1.0, 1.0)
    if isnan(z):
        return (0.5, 0.5, 0.5)
    pi = 3.1415926535898
    a = (float(arg(z)) + pi) / (2 * pi)
    a = (a + 0.5) % 1.0
    b = 1.0 - float(1 / (1.0 + abs(z)**0.3))
    return hls_to_rgb(a, b, 0.8)
Ejemplo n.º 2
0
def default_color_function(z):
    if isinf(z):
        return (1.0, 1.0, 1.0)
    if isnan(z):
        return (0.5, 0.5, 0.5)
    pi = 3.1415926535898
    a = (float(arg(z)) + pi) / (2*pi)
    a = (a + 0.5) % 1.0
    b = 1.0 - float(1/(1.0+abs(z)**0.3))
    return hls_to_rgb(a, b, 0.8)
Ejemplo n.º 3
0
def ellipk(m):
    """Complete elliptic integral of the first kind, K(m). Note that
    the argument is the parameter m = k^2, not the modulus k."""
    # Poor implementation:
    # return pi/2 * sum_hyp2f1_rat((1,2),(1,2),(1,1), m)
    if m == 1:
        return inf
    if isnan(m):
        return m
    if isinf(m):
        return 1/m
    s = sqrt(m)
    a = (1-s)/(1+s)
    v = pi/4*(1+a)/agm(1,a)
    if isinstance(m, mpf) and m < 1:
        return v.real
    return v
Ejemplo n.º 4
0
def ellipk(m):
    """Complete elliptic integral of the first kind, K(m). Note that
    the argument is the parameter m = k^2, not the modulus k."""
    # Poor implementation:
    # return pi/2 * sum_hyp2f1_rat((1,2),(1,2),(1,1), m)
    if m == 1:
        return inf
    if isnan(m):
        return m
    if isinf(m):
        return 1 / m
    s = sqrt(m)
    a = (1 - s) / (1 + s)
    v = pi / 4 * (1 + a) / agm(1, a)
    if isinstance(m, mpf) and m < 1:
        return v.real
    return v