示例#1
0
def sph_convert(v):
    x2 = ek.pow(v.x, 2)
    y2 = ek.pow(v.y, 2)
    z2 = ek.pow(v.z, 2)

    r = ek.sqrt(x2 + y2 + z2)
    phi = ek.atan2(v.y, v.x)
    theta = ek.atan2(ek.sqrt(x2 + y2), v.z)

    return r, theta, phi
示例#2
0
def pow_(a0, a1):
    if not a0.IsFloat:
        raise Exception("pow(): requires floating point operands!")
    if not a0.IsSpecial:
        if isinstance(a1, int) or isinstance(a1, float):
            ar, sr = _check1(a0)
            for i in range(sr):
                ar[i] = _ek.pow(a0[i], a1)
        else:
            ar, sr = _check2(a0, a1)
            for i in range(sr):
                ar[i] = _ek.pow(a0[i], a1[i])
    else:
        return _ek.exp(_ek.log(a0) * a1)
    return ar
示例#3
0
def test10_math_explog():
    for i in range(-5, 5):
        for j in range(-5, 5):
            if i != 0 or j != 0:
                a = ek.log(C(i, j))
                b = C(cmath.log(complex(i, j)))
                assert ek.allclose(a, b)

                a = ek.log2(C(i, j))
                b = C(cmath.log(complex(i, j)) / cmath.log(2))
                assert ek.allclose(a, b)

            a = ek.exp(C(i, j))
            b = C(cmath.exp(complex(i, j)))
            assert ek.allclose(a, b)

            a = ek.exp2(C(i, j))
            b = C(cmath.exp(complex(i, j) * cmath.log(2)))
            assert ek.allclose(a, b)

            a = ek.pow(C(2, 3), C(i, j))
            b = C(complex(2, 3)**complex(i, j))
            assert ek.allclose(a, b)
示例#4
0
def y_2_p2(colors, theta, phi):
    K = ek.sqrt(15.0 / (16 * ek.pi))
    return K * (ek.pow(ek.cos(phi), 2) - ek.pow(ek.sin(phi), 2)) * ek.pow(
        ek.sin(theta), 2) * colors
示例#5
0
def y_2_0(colors, theta, phi):
    K = ek.sqrt(5.0 / (16 * ek.pi))
    return K * (3 * ek.pow(ek.cos(theta), 2) - 1) * colors
示例#6
0
def y_2_n2(colors, theta, phi):
    K = ek.sqrt(15.0 / (4 * ek.pi))
    return K * ek.sin(phi) * ek.cos(phi) * ek.pow(ek.sin(theta), 2) * colors