Ejemplo n.º 1
0
    def test__get_hp_P4(self):

        c0, s0, c1, s1 = sage_var('c0,s0,c1,s1')
        v = sage_vector([1, c0, s0, 0, 0])
        w = sage_vector([1, c1, s1, 0, 0])

        a12, a13, a23, a14, a24, a34 = [90, 0, 0, 0, 0, 0]
        M = get_rot_S3([a12, a13, a23, a14, a24, a34])
        out = get_hp_P4(v, M * w)
        print(out)
        assert str(out) == '[1, -c1*s0 - c0*s1, c0*c1 - s0*s1, 0, 0]'
Ejemplo n.º 2
0
def get_imp( omat, vmat ):
    '''
    Parameters
    ----------
    omat : sage_matrix 
        A 9x9 invertible matrix with entries in QQ[c0,s0]. 
        This matrix represents a projective curve 
        in the automorphism group of the projective 7-sphere.
        Thus "omat" represents a 1-parameter subgroup in Aut(S^7).
                    
    vmat : sage_matrix  
        A 9x9 invertible matrix with entries in QQ. 
        This matrix represents an element in Aut(S^7),
        which transforms a standard circle.    

    Returns
    -------
    list<OrbRing.R>
        A list of elements in QQ[x0,...,x8].
        This list represent the generators of the ideal corresponding to 
        the variety, which is obtained by applying a 1-parameter subgroup to
        a circle C. Here C is the "vmat"-transform of 
        the standard circle B in S^7 where        
        B = { x | -x0^2+x1^2+x2^2==0 } and S^7 = { x | -x0^2+x1^2+...+x8^2==0 }.   
    '''

    # declare list of coordinate variables
    v_lst = OrbRing.coerce( '[v0,v1,v2,v3,v4,v5,v6,v7,v8]' )
    x_lst = OrbRing.coerce( '[x0,x1,x2,x3,x4,x5,x6,x7,x8]' )
    c_lst = OrbRing.coerce( '[c0,s0]' )

    # construct generators of ideal of orbital product
    g_lst = []

    # v[i] coordinates of points on a circle C in S^7
    vmatI = vmat.inverse()
    g_lst += list( vmatI * sage_vector( v_lst ) )[3:]
    g_lst += OrbRing.coerce( '[-v0^2+v1^2+v2^2+v3^2+v4^2+v5^2+v6^2+v7^2+v8^2]' )

    # consider all point that are an orbit of C
    # the 1-parameter subgroup of Aut(S^7)
    # represented by the matrix omat
    e_lst = list( omat * sage_vector( v_lst ) )
    g_lst += [ x_lst[i] - e_lst[i] for i in range( 0, 8 + 1 ) ]
    g_lst += OrbRing.coerce( '[-x0^2+x1^2+x2^2+x3^2+x4^2+x5^2+x6^2+x7^2+x8^2]' )
    g_lst += OrbRing.coerce( '[s0^2+c0^2-1]' )

    # compute the resulting variety by elimination
    g_ideal = OrbRing.R.ideal( g_lst )
    imp_lst = list( g_ideal.elimination_ideal( v_lst + c_lst ).gens() )

    return imp_lst
Ejemplo n.º 3
0
    def test__get_hp_S3(self):
        a01, a02, a03, a12, a13, a23 = 5 * [0] + [2]
        M = get_rot_S3(a01, a02, a03, a12, a13, a23)

        c0, s0, c1, s1 = sage_var('c0,s0,c1,s1')
        v = sage_vector([c0, s0, 0, 0, 1])
        w = sage_vector([c1, s1, 0, 0, 1])

        out = get_hp_S3(v, M * w)

        print(out)

        assert str(out) == '(c0*c1 - s0*s1, c1*s0 + c0*s1, 0, 0, 1)'
Ejemplo n.º 4
0
def get_pmz(A, B, prj):
    '''
    Computes parametrization of a stereographic projection of 
    the pointwise Hamiltonian product of circles in the sphere S^3 
    defined by transformations of the standard circle [1,cos(a),sin(a),0,0]
    by A and B respectively.  

        
    Parameters
    ----------
    A : sage_Matrix<sage_QQ>
        Represents a linear transformation S^3--->S^3
    B : sage_Matrix<sage_QQ>
        Represents a linear transformation S^3--->S^3
    prj : int 
        Choice for stereographic projection S^3--->P^3: 
        0: (x0:x1:x2:x3:x4) |--> (x0-x4:x1:x2:x3)
        1: (x0:x1:x2:x3:x4) |--> (x0-x1:x4:x2:x3)
        2: (x0:x1:x2:x3:x4) |--> (x0-x2:x1:x4:x3)
        3: (x0:x1:x2:x3:x4) |--> (x0-x3:x1:x2:x4)  
    
    Returns
    -------
    tuple
        Returns tuple (baseA, baseB, pmzAB) where
        * baseA: Parametrization of projection of A in cos(a) and sin(a).
        * baseB: Parametrization of projection of B in cos(b) and sin(b).
        * pmzAB: Parametrization of projection of A*B.                     
    '''
    dct = {}

    # Hamiltonian product of circles
    a, b = sage_var('a,b')
    u = list(A * sage_vector([1, sage_cos(a), sage_sin(a), 0, 0]))
    v = list(B * sage_vector([1, sage_cos(b), sage_sin(b), 0, 0]))
    p = get_hp_P4(u, v)

    # stereographic projection
    if prj == 0: j, i_lst = 4, [1, 2, 3]
    if prj == 1: j, i_lst = 1, [4, 2, 3]
    if prj == 2: j, i_lst = 2, [1, 4, 3]
    if prj == 3: j, i_lst = 3, [1, 2, 4]
    p = [p[i] / (p[0] - p[j]) for i in i_lst]

    # put in dictionary
    pmzAB = [elt.full_simplify() for elt in p]
    baseA = [u[i] / (u[0] - u[j]) for i in i_lst]
    baseB = [v[i] / (v[0] - v[j]) for i in i_lst]

    return baseA, baseB, pmzAB
Ejemplo n.º 5
0
    def test__get_prj_S3(self):

        x0, x1, x2, x3, x4 = sage_var('x0,x1,x2,x3,x4')
        v = sage_vector([x1, x2, x3, x4, x0])
        out = get_prj_S3(v)
        print(out)
        assert out == [-x1 / (x0 - x4), -x2 / (x0 - x4), -x3 / (x0 - x4)]
Ejemplo n.º 6
0
def get_pmz( pmat, omat, vmat ):
    '''
    Parameters
    ----------
    pmat : sage_matrix
        A 4x9 invertible matrix with entries in QQ. 
        A matrix represents a projection from 
        a 7-sphere in projective 8-space to projective 3-space.
        
    omat : sage_matrix 
        A 9x9 invertible matrix with entries in QQ[c1,s1]. 
        This matrix represents a projective curve 
        in the automorphism group of the projective 7-sphere.
        Thus "omat" represents a 1-parameter subgroup in Aut(S^7).
                    
    vmat : sage_matrix 
        A 9x9 invertible matrix with entries in QQ. 
        This matrix represents an element in Aut(S^7),
        which transforms a standard circle (see below).
        
    Returns
    -------
    list
        Two lists of elements in QQ[c0,s0,c1,s1].
        The 1st list has length 9 and the 2nd list has length 4.
        The 1st list represent a parametrization 
              S^1xS^1--->S^7
        of a surface in S^7 and the 2nd list the parametrization 
              S^1xS^1--->P^3
        of the surface projected into
        P^3 (projective 3-space) using "pmat". 
        Here (c0,s0) and (c1,s1) are points on S^1.
                    
    Notes
    -----
    The surface in S^7 is obtained by applying a 1-parameter subgroup to a 
    circle C. Here C is the "vmat"-transform of the standard circle B in S^7 
    where
    B = { x | -x0^2+x1^2+x2^2==0 } and S^7 = { x | -x0^2+x1^2+...+x8^2==0 }.             
    '''
    c1, s1 = OrbRing.coerce( 'c1,s1' )
    pmz_lst = list( omat * vmat * sage_vector( [1, c1, s1, 0, 0, 0, 0, 0, 0] ) )
    prj_pmz_lst = list( pmat * omat * vmat * sage_vector( [1, c1, s1, 0, 0, 0, 0, 0, 0] ) )

    return pmz_lst, prj_pmz_lst
Ejemplo n.º 7
0
    def test__get_tmat(self):

        #
        # Setup inverse stereographic projection:
        # S: P^7 ---> S^7
        #
        v = OrbRing.coerce('[v0,v1,v2,v3,v4,v5,v6,v7,v8]')
        d = v[1]**2 + v[2]**2 + v[3]**2
        v0_2 = v[0]**2
        vec_lst = []
        vec_lst += [v0_2 + d]
        vec_lst += [2 * v[0] * v[1]]
        vec_lst += [2 * v[0] * v[2]]
        vec_lst += [2 * v[0] * v[3]]
        vec_lst += [2 * v[0] * v[4]]
        vec_lst += [2 * v[0] * v[5]]
        vec_lst += [2 * v[0] * v[6]]
        vec_lst += [2 * v[0] * v[7]]
        vec_lst += [-v0_2 + d]
        x = sage_vector(OrbRing.R, vec_lst)
        print(x)

        #
        # Setup Euclidean translation in S^7
        #    T:S^7--->S^7
        #
        tmat = get_tmat(None)
        print(tmat)

        #
        # Setup stereographic projection
        #     P:S^7--->P^7
        #
        pmat = []
        pmat += [[1, 0, 0, 0] + [0, 0, 0, 0, -1]]
        pmat += [[0, 1, 0, 0] + [0, 0, 0, 0, 0]]
        pmat += [[0, 0, 1, 0] + [0, 0, 0, 0, 0]]
        pmat += [[0, 0, 0, 1] + [0, 0, 0, 0, 0]]
        pmat += [[0, 0, 0, 0] + [1, 0, 0, 0, 0]]
        pmat += [[0, 0, 0, 0] + [0, 1, 0, 0, 0]]
        pmat += [[0, 0, 0, 0] + [0, 0, 1, 0, 0]]
        pmat += [[0, 0, 0, 0] + [0, 0, 0, 1, 0]]
        pmat = sage_matrix(pmat)
        print(pmat)

        # Check whether composition is an Euclidean
        # translation in P^7:
        #    PoToS
        #
        tv = pmat * tmat * x
        tv = tv / (2 * v[0])
        print(tv)

        assert str(
            tv
        ) == '(v0, v0*t1 + v1, v0*t2 + v2, v0*t3 + v3, v0*t4 + v4, v0*t5 + v5, v0*t6 + v6, v0*t7 + v7)'
Ejemplo n.º 8
0
def spindle_cyclide():
    '''
    Constructs a povray image of a spindle cyclide. The spindle cyclide is
    an inversion of a circular cylinder.
    '''

    # We construct a trigonometric parametrization
    # of the cyclide by rotating a circle.
    #
    r = 1
    R = 1
    # radii of circles
    x, y, v, w = sage_var('x,y,v,w')
    c0, s0, c1, s1 = sage_var('c0,s0,c1,s1')
    V = sage_vector([r * c0 + R, 0, r * s0])
    M = sage_matrix([(c1, -s1, 0), (s1, c1, 0), (0, 0, 1)])
    pmz_AB_lst = [1] + list(M * V)
    OrbTools.p('pmz_AB_lst =', pmz_AB_lst)
    for pmz in pmz_AB_lst:
        OrbTools.p('\t\t', sage_factor(pmz))

    # PovInput spindle cyclide
    #
    pin = PovInput()

    pin.path = './' + get_time_str() + '_spindle_cyclide/'
    pin.fname = 'orb'
    pin.scale = 1
    pin.cam_dct['location'] = (0, -5, 0)
    pin.cam_dct['lookat'] = (0, 0, 0)
    pin.cam_dct['rotate'] = (45, 0, 0)
    pin.shadow = True
    pin.light_lst = [(1, 0, 0), (0, 1, 0), (0, 0, 1), (-1, 0, 0), (0, -1, 0),
                     (0, 0, -1), (10, 0, 0), (0, 10, 0), (0, 0, 10),
                     (-10, 0, 0), (0, -10, 0), (0, 0, -10)]
    pin.axes_dct['show'] = False
    pin.axes_dct['len'] = 1.2
    pin.height = 400
    pin.width = 800
    pin.quality = 11
    pin.ani_delay = 10

    pin.impl = None

    pin.pmz_dct['A'] = (pmz_AB_lst, 0)
    pin.pmz_dct['B'] = (pmz_AB_lst, 1)

    pin.pmz_dct['FA'] = (pmz_AB_lst, 0)
    pin.pmz_dct['FB'] = (pmz_AB_lst, 1)

    v0_lst = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 10)]

    v1_lst_A = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 270, 15)]
    v1_lst_B = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 180, 15)]

    v1_lstFA = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 270 - 15, 1)]
    v1_lstFB = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 180, 1)]

    pin.curve_dct['A'] = {
        'step0': v0_lst,
        'step1': v1_lst_A,
        'prec': 10,
        'width': 0.03
    }
    pin.curve_dct['B'] = {
        'step0': v0_lst,
        'step1': v1_lst_B,
        'prec': 10,
        'width': 0.03
    }
    pin.curve_dct['FA'] = {
        'step0': v0_lst,
        'step1': v1_lstFA,
        'prec': 10,
        'width': 0.02
    }
    pin.curve_dct['FB'] = {
        'step0': v0_lst,
        'step1': v1_lstFB,
        'prec': 10,
        'width': 0.02
    }

    col_A = (0.6, 0.4, 0.1, 0.0)
    col_B = (0.1, 0.15, 0.0, 0.0)
    colFF = (0.1, 0.1, 0.1, 0.0)
    pin.text_dct['A'] = [True, col_A, 'phong 0.2 phong_size 5']
    pin.text_dct['B'] = [True, col_B, 'phong 0.2 phong_size 5']
    pin.text_dct['FA'] = [True, colFF, 'phong 0.2 phong_size 5']
    pin.text_dct['FB'] = [True, colFF, 'phong 0.2 phong_size 5']

    # raytrace image/animation
    create_pov(pin, ['A', 'B'])
    create_pov(pin, ['A', 'B', 'FA', 'FB'])
Ejemplo n.º 9
0
def get_imp(A, B, prj, sng, snp):
    '''
    Computes implicit equation of a stereographic projection S of 
    the pointwise Hamiltonian product of circles in the sphere S^3 
    defined by transformations of the standard circle [1,cos(a),sin(a),0,0]
    by A and B respectively.     
        
    Parameters
    ----------
    A : sage_Matrix<sage_QQ>
        Represents a linear transformation S^3--->S^3
    
    B : sage_Matrix<sage_QQ>
        Represents a linear transformation S^3--->S^3
    
    prj : int
        Choice for stereographic projection S^3--->P^3: 
        0: (x0:x1:x2:x3:x4) |--> (x0-x4:x1:x2:x3)
        1: (x0:x1:x2:x3:x4) |--> (x0-x1:x4:x2:x3)
        2: (x0:x1:x2:x3:x4) |--> (x0-x2:x1:x4:x3)
        3: (x0:x1:x2:x3:x4) |--> (x0-x3:x1:x2:x4)
    
    sng : boolean
        If true computes singular locus of S. Needs Magma path set
        in os.environ['PATH']. Otherwise the empty-list is returned.

    snp : boolean
        If true and if sng is True, then the singular locus is 
        computed with a probablistic method, which is faster but
        the correctness of the output is not guaranteed.
        
    Returns
    -------
    dict
        {   
            'Agreat' : boolean
                If True, then circle A is great.
                
            'Bgreat' : boolean
                If True, then circle B is great.
            
            'eqn_x'  : sage_PolynomialRing
                Equation of S in x0,...,x3

            'eqn_str':
                Formatted equation in x0,...,x3 of the 
                form f(x1:x2:x3)+x0*g(x0:x1:x2:x3).
            
            'eqn_xyz':
                Equation of S in x,y,z
                        
            'sng_lst':
                Empty-list if Magma is not installed or 
                list of singularities of S otherwise.
        }
        
    '''

    dct = {}  # output

    # create polynomial ring
    #
    R = sage_PolynomialRing(sage_QQ,
                            'x0,x1,x2,x3,a0,a1,a2,a3,a4,b0,b1,b2,b3,b4')
    x0, x1, x2, x3, a0, a1, a2, a3, a4, b0, b1, b2, b3, b4 = R.gens()

    # construct ideal for A
    #
    sv = [0, 0, 0, 1, 0]
    tv = [0, 0, 0, 0, 1]
    u0, u1, u2, u3, u4 = list(A * sage_vector(sv))
    v0, v1, v2, v3, v4 = list(A * sage_vector(tv))
    eqA = [-a0**2 + a1**2 + a2**2 + a3**2 + a4**2]
    eqA += [u0 * a0 + u1 * a1 + u2 * a2 + u3 * a3 + u4 * a4]
    eqA += [v0 * a0 + v1 * a1 + v2 * a2 + v3 * a3 + v4 * a4]
    dct['Agreat'] = u0 == v0 == 0

    # construct ideal for B
    #
    u0, u1, u2, u3, u4 = list(B * sage_vector(sv))
    v0, v1, v2, v3, v4 = list(B * sage_vector(tv))
    eqB = [-b0**2 + b1**2 + b2**2 + b3**2 + b4**2]
    eqB += [u0 * b0 + u1 * b1 + u2 * b2 + u3 * b3 + u4 * b4]
    eqB += [v0 * b0 + v1 * b1 + v2 * b2 + v3 * b3 + v4 * b4]
    dct['Bgreat'] = u0 == v0 == 0

    # stereographic projection
    #
    if prj == 0: j, i_lst = 4, [1, 2, 3]
    if prj == 1: j, i_lst = 1, [4, 2, 3]
    if prj == 2: j, i_lst = 2, [1, 4, 3]
    if prj == 3: j, i_lst = 3, [1, 2, 4]

    # construct equation of for projection of A*B
    #
    c = c0, c1, c2, c3, c4 = get_hp_P4([a0, a1, a2, a3, a4],
                                       [b0, b1, b2, b3, b4])
    x = [x0, x1, x2, x3]
    i1, i2, i3 = i_lst
    id = [x[0] -
          (c[0] - c[j]), x[1] - c[i1], x2 - c[i2], x3 - c[i3]] + eqA + eqB
    dct['eqn_x'] = eqn_x = R.ideal(id).elimination_ideal(
        [a0, a1, a2, a3, a4, b0, b1, b2, b3, b4]).gens()[0]

    # get equation in string form
    #
    f = eqn_x.subs({x0: 0})
    dct['eqn_str'] = str(sage_factor(f)) + '+' + str(sage_factor(eqn_x - f))
    xs, ys, zs = sage_var('x,y,z')
    dct['eqn_xyz'] = sage_SR(eqn_x.subs({x0: 1, x1: xs, x2: ys, x3: zs}))

    # compute singular locus
    #
    dct['sng_lst'] = []
    if sng:
        dct['sng_lst'] = get_sing_lst(OrbRing.coerce(eqn_x), snp)

    return dct
Ejemplo n.º 10
0
def get_project( pol_lst, pmat ):
    '''
    Parameters
    ----------
    pol_lst : list<OrbRing.R> 
        A list of homogeneous polynomials in QQ[x0,...,x8].
    
    pmat : sage_matrix    
        A matrix defined over the rationals QQ.    
    
    Returns
    -------
    tuple
        A 2-tuple of polynomials:        
        * a homogeneous polynomial F in QQ[x0,x1,x2,x3].             
        * F(1,x,y,z) in QQ[x,y,z] (affine polynomial)
    '''

    Ry = sage_PolynomialRing( sage_GF( 2 ), sage_var( 'y0,y1,y2,y3,y4,y5,y6,y7,y8' ), order = 'degrevlex' )
    v = OrbRing.coerce( '[v0,v1,v2,v3,v4,v5,v6,v7,v8]' )
    x = OrbRing.coerce( '[x0,x1,x2,x3,x4,x5,x6,x7,x8]' )
    vx_dct = {v[i]:x[i] for i in range( 9 )}

    OrbTools.p( "\n" + str( pmat ) )

    tries = 0
    projected = False
    while not projected:

        # obtain the linear equations of the projection map
        pmat = sage_matrix( OrbRing.R, list( pmat ) )
        leq_lst = list( pmat * sage_vector( x ) )

        # compute the image of this projection map
        proj_lst = [ v[i] - leq_lst[i] for i in range( len( leq_lst ) ) ]
        p_lst = sage_ideal( pol_lst + proj_lst ).elimination_ideal( x ).gens()

        # obtain a polynomial in x0,...,x8
        p_lst = [p.subs( vx_dct ) for p in p_lst]
        fx = p_lst[0]

        tries += 1
        if len( fx.variables() ) < 4 or len( p_lst ) != 1:

            pmat = get_pmat( True )

            if tries % 100 == 0:
                OrbTools.p( 'tries =', tries, p_lst )

            if tries == 1000:
                return -1
        else:
            projected = True

    w0, w1, w2, w3 = fx.variables()
    fx = fx.subs( {w0:x[0], w1:x[1], w2:x[2], w3:x[3]} )

    x0, x1, x2, x3 = OrbRing.coerce( 'x0,x1,x2,x3' )
    x, y, z = sage_var( 'x,y,z' )
    fxyz = fx.subs( {x0:1, x1:x, x2:y, x3:z} )

    OrbTools.p( fx )
    OrbTools.p( fxyz )

    return fx, fxyz
Ejemplo n.º 11
0
def ring_cyclide():
    '''
    Creates povray image of 4 families of circles on a ring cyclide. 
    '''

    # We construct a trigonometric parametrization of the ring cyclide,
    # by rotating a circle of radius r along a circle of radius R.
    R = 2
    r = 1
    x, y, v, w, c0, s0, c1, s1 = sage_var('x,y,v,w,c0,s0,c1,s1')
    V = sage_vector([r * c0 + R, 0, r * s0])
    M = sage_matrix([(c1, -s1, 0), (s1, c1, 0), (0, 0, 1)])
    pmz_AB_lst = [1] + list(M * V)
    OrbTools.p('pmz_AB_lst =', pmz_AB_lst)
    for pmz in pmz_AB_lst:
        OrbTools.p('\t\t', sage_factor(pmz))

    # convert pmz_AB_lst to rational parametrization pmz_lst
    C0 = (y**2 - x**2) / (y**2 + x**2)
    S0 = 2 * x * y / (y**2 + x**2)
    C1 = (w**2 - v**2) / (w**2 + v**2)
    S1 = 2 * v * w / (w**2 + v**2)
    den = (y**2 + x**2) * (w**2 + v**2)
    dct = {c0: C0, s0: S0, c1: C1, s1: S1}
    pmz_lst = [den] + [(elt.subs(dct) * den).simplify_full()
                       for elt in list(M * V)]
    OrbTools.p('pmz_lst =', pmz_lst)

    # find basepoints
    ls = LinearSeries(pmz_lst, PolyRing('x,y,v,w', True))
    OrbTools.p(ls.get_bp_tree())

    # construct linear series for families of conics
    a0, a1 = PolyRing('x,y,v,w').ext_num_field('t^2+1/3').ext_num_field(
        't^2+1').root_gens()

    p1 = ['xv', (-a0, a1)]
    p2 = ['xv', (a0, -a1)]
    p3 = ['xv', (-a0, -a1)]
    p4 = ['xv', (a0, a1)]

    bpt_1234 = BasePointTree(['xv', 'xw', 'yv', 'yw'])
    bpt_1234.add(p1[0], p1[1], 1)
    bpt_1234.add(p2[0], p2[1], 1)
    bpt_1234.add(p3[0], p3[1], 1)
    bpt_1234.add(p4[0], p4[1], 1)

    bpt_12 = BasePointTree(['xv', 'xw', 'yv', 'yw'])
    bpt_12.add(p1[0], p1[1], 1)
    bpt_12.add(p2[0], p2[1], 1)

    bpt_34 = BasePointTree(['xv', 'xw', 'yv', 'yw'])
    bpt_34.add(p3[0], p3[1], 1)
    bpt_34.add(p4[0], p4[1], 1)

    ls_22 = LinearSeries.get([2, 2], bpt_1234)  # |2(l1+l2)-e1-e2-e3-e4|
    ls_21 = LinearSeries.get([2, 1], bpt_1234)
    ls_12 = LinearSeries.get([1, 2], bpt_1234)
    ls_11a = LinearSeries.get([1, 1], bpt_12)
    ls_11b = LinearSeries.get([1, 1], bpt_34)

    OrbTools.p('linear series 22 =\n', ls_22)
    OrbTools.p('linear series 21 =\n', ls_21)
    OrbTools.p('linear series 12 =\n', ls_12)
    OrbTools.p('linear series 11a =\n', ls_11a)
    OrbTools.p('linear series 11b =\n', ls_11b)

    # compute reparametrization
    ring = PolyRing(
        'x,y,v,w,c0,s0,c1,s1')  # construct polynomial ring with new generators
    pmz_lst = ring.coerce(pmz_lst)
    x, y, v, w, c0, s0, c1, s1 = ring.gens()
    X = 1 - s0
    Y = c0
    # see get_S1xS1_pmz()
    V = 1 - s1
    W = c1
    q = sage_n(sage_sqrt(3)).exact_rational()  # approximation of sqrt(3)
    CB_dct = {x: X, y: Y, v: W * X + q * V * Y, w: V * X - q * W * Y}
    DB_dct = {x: X, y: Y, v: W * X - q * V * Y, w: V * X + q * W * Y}
    pmz_CB_lst = [pmz.subs(CB_dct) for pmz in pmz_lst]
    pmz_DB_lst = [pmz.subs(DB_dct) for pmz in pmz_lst]

    # output
    OrbTools.p('pmz_AB_lst =\n', pmz_AB_lst)
    OrbTools.p('pmz_CB_lst =\n', pmz_CB_lst)
    OrbTools.p('pmz_DB_lst =\n', pmz_DB_lst)

    # mathematica
    for pmz, AB in [(pmz_AB_lst, 'AB'), (pmz_CB_lst, 'CB'),
                    (pmz_DB_lst, 'DB')]:
        s = 'pmz' + AB + '=' + str(pmz) + ';'
        s = s.replace('[', '{').replace(']', '}')
        print(s)

    # PovInput ring cyclide
    #
    pin = PovInput()

    pin.path = './' + get_time_str() + '_ring_cyclide/'
    pin.fname = 'orb'
    pin.scale = 1
    pin.cam_dct['location'] = (0, -7, 0)
    pin.cam_dct['lookat'] = (0, 0, 0)
    pin.cam_dct['rotate'] = (55, 0, 0)  # 45
    pin.shadow = True
    pin.light_lst = [(0, 0, -5), (0, -5, 0), (-5, 0, 0), (0, 0, 5), (0, 5, 0),
                     (5, 0, 0), (-5, -5, -5), (5, -5, 5), (-5, -5, 5),
                     (5, -5, -5)]
    pin.axes_dct['show'] = False
    pin.axes_dct['len'] = 1.2
    pin.width = 800
    pin.height = 400
    pin.quality = 11
    pin.ani_delay = 10

    pin.impl = None

    pin.pmz_dct['A'] = (pmz_AB_lst, 0)
    pin.pmz_dct['B'] = (pmz_AB_lst, 1)
    pin.pmz_dct['C'] = (pmz_CB_lst, 0)
    pin.pmz_dct['D'] = (pmz_DB_lst, 0)
    pin.pmz_dct['FA'] = (pmz_AB_lst, 0)
    pin.pmz_dct['FB'] = (pmz_AB_lst, 1)
    pin.pmz_dct['FC'] = (pmz_CB_lst, 0)
    pin.pmz_dct['FD'] = (pmz_DB_lst, 0)
    pin.pmz_dct['WA'] = (pmz_AB_lst, 0)
    pin.pmz_dct['WB'] = (pmz_AB_lst, 1)
    pin.pmz_dct['WC'] = (pmz_CB_lst, 0)
    pin.pmz_dct['WD'] = (pmz_DB_lst, 0)

    v0_lst = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 10)]
    v1_lst = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 24)]

    v1_lst_A = [
        sage_pi / 2 + (sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 12)
    ]
    v1_lstFF = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 1)]

    v1_lst_WA = [
        0.1, 0.52, 0.94, 1.36, 1.78, 2.2, 2.61, 3.04, 3.45, 3.88, 4.3, 4.712,
        5.13, 5.55, 5.965
    ]
    v1_lst_WB = [
        0, 0.7, 1.31, 1.8, 2.18, 2.5, 2.77, 3.015, 3.26, 3.51, 3.78, 4.099,
        4.49, 4.97, 5.579
    ]
    v1_lst_WD = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 24)]
    v1_lst_WC = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 24)]

    pin.curve_dct['A'] = {
        'step0': v0_lst,
        'step1': v1_lst_A,
        'prec': 10,
        'width': 0.05
    }
    pin.curve_dct['B'] = {
        'step0': v0_lst,
        'step1': v1_lst,
        'prec': 10,
        'width': 0.05
    }
    pin.curve_dct['C'] = {
        'step0': v0_lst,
        'step1': v1_lst,
        'prec': 10,
        'width': 0.05
    }
    pin.curve_dct['D'] = {
        'step0': v0_lst,
        'step1': v1_lst,
        'prec': 10,
        'width': 0.05
    }
    pin.curve_dct['FA'] = {
        'step0': v0_lst,
        'step1': v1_lstFF,
        'prec': 10,
        'width': 0.02
    }
    pin.curve_dct['FB'] = {
        'step0': v0_lst,
        'step1': v1_lstFF,
        'prec': 10,
        'width': 0.02
    }
    pin.curve_dct['FC'] = {
        'step0': v0_lst,
        'step1': v1_lstFF,
        'prec': 10,
        'width': 0.02
    }
    pin.curve_dct['FD'] = {
        'step0': v0_lst,
        'step1': v1_lstFF,
        'prec': 10,
        'width': 0.02
    }
    pin.curve_dct['WA'] = {
        'step0': v0_lst,
        'step1': v1_lst_WA,
        'prec': 10,
        'width': 0.05
    }
    pin.curve_dct['WB'] = {
        'step0': v0_lst,
        'step1': v1_lst_WB,
        'prec': 10,
        'width': 0.05
    }
    pin.curve_dct['WC'] = {
        'step0': v0_lst,
        'step1': v1_lst_WC,
        'prec': 10,
        'width': 0.05
    }
    pin.curve_dct['WD'] = {
        'step0': v0_lst,
        'step1': v1_lst_WD,
        'prec': 10,
        'width': 0.05
    }

    # A = | rotated circle
    # B = - horizontal circle
    # C = / villarceau circle
    # D = \ villarceau circle
    col_A = rgbt2pov((28, 125, 154, 0))  # blue
    col_B = rgbt2pov((74, 33, 0, 0))  # brown
    col_C = rgbt2pov((75, 102, 0, 0))  # green
    col_D = rgbt2pov((187, 46, 0, 0))  # red/orange
    colFF = rgbt2pov((179, 200, 217, 0))  # light blue

    pin.text_dct['A'] = [True, col_A, 'phong 0.2 phong_size 5']
    pin.text_dct['B'] = [True, col_B, 'phong 0.2 phong_size 5']
    pin.text_dct['C'] = [True, col_C, 'phong 0.2 phong_size 5']
    pin.text_dct['D'] = [True, col_D, 'phong 0.2 phong_size 5']
    pin.text_dct['FA'] = [True, colFF, 'phong 0.2 phong_size 5']
    pin.text_dct['FB'] = [True, colFF, 'phong 0.2 phong_size 5']
    pin.text_dct['FC'] = [True, colFF, 'phong 0.2 phong_size 5']
    pin.text_dct['FD'] = [True, colFF, 'phong 0.2 phong_size 5']
    pin.text_dct['WA'] = [True, col_A, 'phong 0.2 phong_size 5']
    pin.text_dct['WB'] = [True, col_B, 'phong 0.2 phong_size 5']
    pin.text_dct['WC'] = [True, col_C, 'phong 0.2 phong_size 5']
    pin.text_dct['WD'] = [True, col_D, 'phong 0.2 phong_size 5']

    # raytrace image/animation
    create_pov(pin, ['A', 'C', 'D'])
    create_pov(pin, ['A', 'C', 'D'] + ['FA', 'FC', 'FD'])

    create_pov(pin, ['WA', 'WB', 'WC', 'WD'])
    create_pov(pin, ['WA', 'WB', 'WC', 'WD'] + ['FA', 'FC', 'FD'])

    create_pov(pin, ['WA', 'WB', 'WD'])
    create_pov(pin, ['WA', 'WB', 'WD'] + ['FA', 'FC', 'FD'])
Ejemplo n.º 12
0
def dp8_clifford():
    '''    
    Construct povray image of octic del Pezzo surface in S^3.
    The surface is created as the Clifford translation of a
    great circle along a little circle.        
    '''

    # construct surface as pointwise hamiltonian product of
    # two circles in S^3
    #
    T = get_trn_S3([0, 0, 0])
    R = get_rot_S3(6 * [0])
    S = get_scale_S3(1)
    A = S * R * T

    q32 = sage_QQ(3) / 2
    T = get_trn_S3([q32, 0, 0])
    R = get_rot_S3(6 * [0])
    S = get_scale_S3(1)
    B = S * R * T

    c0, s0, c1, s1 = OrbRing.coerce('c0,s0,c1,s1')
    u = list(A * sage_vector([1, c0, s0, 0, 0]))
    v = list(B * sage_vector([1, c1, s1, 0, 0]))
    p = get_hp_P4(u, v)
    pmz_AB_lst = [p[0] - p[4], p[1], p[2], p[3]]

    for pmz in pmz_AB_lst:
        OrbTools.p('\t\t', sage_factor(pmz))

    # PovInput dp8 clifford
    #
    pin = PovInput()

    pin.path = './' + get_time_str() + '_dp8_clifford/'
    pin.fname = 'orb'
    pin.scale = 1
    pin.cam_dct['location'] = (0, 0, 4)
    pin.cam_dct['lookat'] = (0, 0, 0)
    pin.cam_dct['rotate'] = (0, 0, 0)
    pin.shadow = True
    pin.light_lst = [(0, 0, -10), (0, -10, 0), (-10, 0, 0), (0, 0, 10),
                     (0, 10, 0), (10, 0, 0)]
    pin.axes_dct['show'] = False
    pin.axes_dct['len'] = 1.2
    pin.height = 400
    pin.width = 800
    pin.quality = 11
    pin.ani_delay = 10

    pin.impl = None

    pin.pmz_dct['A'] = (pmz_AB_lst, 0)
    pin.pmz_dct['B'] = (pmz_AB_lst, 1)

    pin.pmz_dct['FA'] = (pmz_AB_lst, 0)
    pin.pmz_dct['FB'] = (pmz_AB_lst, 1)

    v0_lst = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 5)]
    v1_lst_A = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 180, 10)]
    v1_lst_A += [(sage_QQ(i) / 180) * sage_pi for i in range(180, 360, 20)]
    v1_lst_B = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 10)]

    v1_lst_FA = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 180, 1)]
    v1_lst_FA += [(sage_QQ(i) / 180) * sage_pi for i in range(180, 360, 2)]
    v1_lst_FB = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 1)]

    pin.curve_dct['A'] = {
        'step0': v0_lst,
        'step1': v1_lst_A,
        'prec': 10,
        'width': 0.04
    }
    pin.curve_dct['B'] = {
        'step0': v0_lst,
        'step1': v1_lst_B,
        'prec': 10,
        'width': 0.04
    }
    pin.curve_dct['FA'] = {
        'step0': v0_lst,
        'step1': v1_lst_FA,
        'prec': 10,
        'width': 0.02
    }
    pin.curve_dct['FB'] = {
        'step0': v0_lst,
        'step1': v1_lst_FB,
        'prec': 10,
        'width': 0.02
    }

    col_A = (0.6, 0.4, 0.1, 0.0)
    col_B = (0.1, 0.15, 0.0, 0.0)
    colFF = (0.1, 0.1, 0.1, 0.0)
    pin.text_dct['A'] = [True, col_A, 'phong 0.2 phong_size 5']
    pin.text_dct['B'] = [True, col_B, 'phong 0.2 phong_size 5']
    pin.text_dct['FA'] = [True, colFF, 'phong 0.2 phong_size 5']
    pin.text_dct['FB'] = [True, colFF, 'phong 0.2 phong_size 5']

    # raytrace image/animation
    create_pov(pin, ['A', 'B'])
    create_pov(pin, ['A', 'B', 'FA', 'FB'])
    create_pov(pin, ['A', 'FA', 'FB'])
    create_pov(pin, ['B', 'FA', 'FB'])
Ejemplo n.º 13
0
def dp6_smooth():
    '''
    Creates povray image of the projection of a smooth sextic del Pezzo 
    surface in S^5. This surface contains 3 families of conics that 
    form a hexagonal web. 
    '''

    # compute parametrizations of canonical model
    a0 = PolyRing('x,y,v,w', True).ext_num_field('t^2 + 1').root_gens()[0]
    bp_tree = BasePointTree(['xv', 'xw', 'yv', 'yw'])
    bp = bp_tree.add('xv', (-a0, a0), 1)
    bp = bp_tree.add('xv', (a0, -a0), 1)
    ls_AB = LinearSeries.get([2, 2], bp_tree)
    ls_CB = LinearSeries.get([1, 1], bp_tree)

    # compute surface in quadric of signature (6,1)
    c_lst = [-1, -1, 0, 0, 0, -1, 1, 0, -1, -1, -1]
    dct = get_surf(ls_AB, (6, 1), c_lst)

    # compute projection to P^3
    U, J = dct['UJ']
    U.swap_rows(0, 6)
    J.swap_columns(0, 6)
    J.swap_rows(0, 6)
    approxU = approx_QQ(U)
    P = get_prj_mat(4, 7, 0)
    P[0, 6] = -1
    P[3, 3] = 0
    P[3, 4] = 1
    P = P * approxU
    f_xyz, pmz_AB_lst = get_proj(dct['imp_lst'], dct['pmz_lst'], P)

    # compute reparametrization
    ring = PolyRing(
        'x,y,v,w,c0,s0,c1,s1')  # construct polynomial ring with new generators
    x, y, v, w, c0, s0, c1, s1 = ring.gens()
    X = 1 - s0
    Y = c0
    # see get_S1xS1_pmz()
    V = 1 - s1
    W = c1
    CB_dct = {x: X, y: Y, v: X * W + Y * V, w: X * V - Y * W}
    pmz_CB_lst = [p.subs(CB_dct) for p in ring.coerce(ls_AB.pol_lst)]
    pmz_CB_lst = list(P * dct['Q'] * sage_vector(pmz_CB_lst))

    # set PovInput as container
    # put very low quality for testing purposes
    pin = PovInput()

    pin.path = './' + get_time_str() + '_dp6_smooth/'
    pin.fname = 'orb'
    pin.scale = 1
    pin.cam_dct['location'] = (0, 0, sage_QQ(-21) / 10)
    pin.cam_dct['lookat'] = (0, 0, 0)
    pin.cam_dct['rotate'] = (310, 0, 0)
    pin.shadow = True
    pin.light_lst = [(0, 0, -4), (0, -4, 0), (-4, 0, 0), (0, 4, 0), (4, 0, 0),
                     (-5, -5, -5), (5, 5, -5), (-5, 5, -5), (5, -5, -5)]
    pin.axes_dct['show'] = False
    pin.axes_dct['len'] = 1.2
    pin.height = 400
    pin.width = 800
    pin.quality = 11
    pin.ani_delay = 1
    pin.impl = None

    v0_lst = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 10)]
    v1_lst = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 15)]
    v1_F_lst = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 1)]

    pin.pmz_dct['A'] = (pmz_AB_lst, 0)
    pin.pmz_dct['B'] = (pmz_AB_lst, 1)
    pin.pmz_dct['C'] = (pmz_CB_lst, 0)
    pin.pmz_dct['FA'] = (pmz_AB_lst, 0)
    pin.pmz_dct['FB'] = (pmz_AB_lst, 1)
    pin.pmz_dct['FC'] = (pmz_CB_lst, 0)

    pin.curve_dct['A'] = {
        'step0': v0_lst,
        'step1': v1_lst,
        'prec': 10,
        'width': 0.018
    }
    pin.curve_dct['B'] = {
        'step0': v0_lst,
        'step1': v1_lst,
        'prec': 10,
        'width': 0.018
    }
    pin.curve_dct['C'] = {
        'step0': v0_lst,
        'step1': v1_lst,
        'prec': 10,
        'width': 0.018
    }
    pin.curve_dct['FA'] = {
        'step0': v0_lst,
        'step1': v1_F_lst,
        'prec': 10,
        'width': 0.003
    }
    pin.curve_dct['FB'] = {
        'step0': v0_lst,
        'step1': v1_F_lst,
        'prec': 10,
        'width': 0.003
    }
    pin.curve_dct['FC'] = {
        'step0': v0_lst,
        'step1': v1_F_lst,
        'prec': 10,
        'width': 0.003
    }

    # ( 0.4, 0.0, 0.0, 0.0 ), ( 0.2, 0.3, 0.2, 0.0 ), ( 0.8, 0.6, 0.2, 0.0 )
    col_A = rgbt2pov((75, 102, 0, 0))  # green /
    col_B = rgbt2pov((74, 33, 0, 0))  # brown -
    col_C = rgbt2pov((28, 125, 154, 0))  # blue \
    colFF = rgbt2pov((179, 200, 217, 0))  # light blue

    pin.text_dct['A'] = [True, col_A, 'phong 0.2']
    pin.text_dct['B'] = [True, col_B, 'phong 0.2']
    pin.text_dct['C'] = [True, col_C, 'phong 0.2']
    pin.text_dct['FA'] = [True, colFF, 'phong 0.8']
    pin.text_dct['FB'] = [True, colFF, 'phong 0.8']
    pin.text_dct['FC'] = [True, colFF, 'phong 0.8']

    # raytrace image/animation
    create_pov(pin, ['A', 'B', 'C'])
    create_pov(pin, ['A', 'B', 'C', 'FA', 'FB', 'FC'])
    create_pov(pin, ['A', 'FA', 'FB', 'FC'])
    create_pov(pin, ['B', 'FA', 'FB', 'FC'])
    create_pov(pin, ['C', 'FA', 'FB', 'FC'])
Ejemplo n.º 14
0
def CH1_cyclide():
    '''
    Creates povray image of a CH1 cyclide, which is
    an inversion of a Circular Hyperboloid of 1 sheet.    
    '''

    # Construct a trigonometric parametrization by rotating a circle.
    r, R = 1, 1
    c0, s0, c1, s1 = sage_var('c0,s0,c1,s1')
    x, y, v, w, a0 = sage_var('x,y,v,w,a0')
    q2 = sage_QQ(1) / 2
    MX = sage_matrix([(1, 0, 0), (0, c1, s1), (0, -s1, c1)])
    MXc = MX.subs({c1: a0, s1: a0})  # a0=1/sqrt(2)=cos(pi/4)=sin(pi/4)
    MZ = sage_matrix([(c1, s1, 0), (-s1, c1, 0), (0, 0, 1)])
    V = sage_vector([r * c0, 0, r * s0])
    V = MXc * V
    V[0] = V[0] + R
    pmz_AB_lst = list(MZ * V)
    OrbTools.p('V =', V)
    OrbTools.p('pmz_AB_lst =', pmz_AB_lst)
    for pmz in pmz_AB_lst:
        OrbTools.p('\t\t', sage_factor(pmz))

    # Convert the trigonometric parametrization to a rational parametrization
    # We convert via the following formulas,
    #
    #     cos(s) = (y^2-x^2) / (y^2+x^2)
    #     sin(s) = 2*x*y / (y^2+x^2)
    #     y=1; x = arctan( s/2 )
    #
    C0 = (y**2 - x**2) / (y**2 + x**2)
    S0 = 2 * x * y / (y**2 + x**2)
    C1 = (w**2 - v**2) / (w**2 + v**2)
    S1 = 2 * v * w / (w**2 + v**2)
    den = (y**2 + x**2) * (w**2 + v**2)
    dct = {c0: C0, s0: S0, c1: C1, s1: S1}
    pmz_lst = [den] + [(elt.subs(dct) * den).simplify_full()
                       for elt in list(MZ * V)]
    OrbTools.p('pmz_lst =', pmz_lst)
    for pmz in pmz_lst:
        OrbTools.p('\t\t', sage_factor(pmz))

    # do a basepoint analysis on the rational parametrization
    # The True argument is for resetting the number field to QQ!
    ring = PolyRing('x,y,v,w', True).ext_num_field('t^2-1/2')
    ls = LinearSeries([str(pmz) for pmz in pmz_lst], ring)
    OrbTools.p(ls.get_bp_tree())

    # construct linear series for families of conics
    ring = PolyRing(
        'x,y,v,w')  # construct polynomial ring over new ground field
    OrbTools.p(ring)
    x, y, v, w = ring.gens()
    a0, a1 = ring.root_gens()

    p1 = ['xv', (0, 2 * a0 * a1)]
    p2 = ['xv', (0, -2 * a0 * a1)]
    p3 = ['xv', (a1, 2 * a0 * a1)]
    p4 = ['xv', (-a1, -2 * a0 * a1)]

    bpt_1234 = BasePointTree(['xv', 'xw', 'yv', 'yw'])
    bpt_1234.add(p1[0], p1[1], 1)
    bpt_1234.add(p2[0], p2[1], 1)
    bpt_1234.add(p3[0], p3[1], 1)
    bpt_1234.add(p4[0], p4[1], 1)

    bpt_12 = BasePointTree(['xv', 'xw', 'yv', 'yw'])
    bpt_12.add(p1[0], p1[1], 1)
    bpt_12.add(p2[0], p2[1], 1)

    bpt_34 = BasePointTree(['xv', 'xw', 'yv', 'yw'])
    bpt_34.add(p3[0], p3[1], 1)
    bpt_34.add(p4[0], p4[1], 1)

    ls_22 = LinearSeries.get([2, 2], bpt_1234)  # |2(l1+l2)-e1-e2-e3-e4|
    ls_21 = LinearSeries.get([2, 1], bpt_1234)
    ls_12 = LinearSeries.get([1, 2], bpt_1234)
    ls_11a = LinearSeries.get([1, 1], bpt_12)
    ls_11b = LinearSeries.get([1, 1], bpt_34)

    OrbTools.p('linear series 22 =\n', ls_22)
    OrbTools.p('linear series 21 =\n', ls_21)
    OrbTools.p('linear series 12 =\n', ls_12)
    OrbTools.p('linear series 11a =\n', ls_11a)
    OrbTools.p('linear series 11b =\n', ls_11b)

    # compute reparametrization from the linear series of families
    ring = PolyRing(
        'x,y,v,w,c0,s0,c1,s1')  # construct polynomial ring with new generators
    OrbTools.p(ring)
    x, y, v, w, c0, s0, c1, s1 = ring.gens()
    a0, a1 = ring.root_gens()
    pmz_AB_lst = [1] + ring.coerce(pmz_AB_lst)
    pmz_lst = ring.coerce(pmz_lst)

    X = 1 - s0
    Y = c0
    V = 1 - s1
    W = c1
    CB_dct = {
        x: X,
        y: Y,
        v: W * X - 2 * a0 * V * Y,
        w: V * X + 2 * a0 * W * Y
    }
    pmz_CB_lst = [pmz.subs(CB_dct) for pmz in pmz_lst]  # CB  11b

    # output
    OrbTools.p('pmz_AB_lst =\n', pmz_AB_lst)
    OrbTools.p('pmz_CB_lst =\n', pmz_CB_lst)

    # approximate by map defined over rational numbers
    ci_idx = 0  # index defining the complex embedding
    OrbTools.p('complex embeddings =')
    for i in range(len(a0.complex_embeddings())):
        a0q = OrbRing.approx_QQ_coef(a0, i)
        OrbTools.p('\t\t' + str(i) + ' =', a0q, sage_n(a0q))
    pmz_AB_lst = OrbRing.approx_QQ_pol_lst(pmz_AB_lst, ci_idx)
    pmz_CB_lst = OrbRing.approx_QQ_pol_lst(pmz_CB_lst, ci_idx)

    # mathematica input
    ms = ''
    for pmz, AB in [(pmz_lst, 'ZZ'), (pmz_AB_lst, 'AB'), (pmz_CB_lst, 'CB')]:
        s = 'pmz' + AB + '=' + str(pmz) + ';'
        s = s.replace('[', '{').replace(']', '}')
        ms += '\n' + s
    OrbTools.p('Mathematica input =', ms)

    # PovInput ring cyclide
    #
    pin = PovInput()

    pin.path = './' + get_time_str() + '_CH1_cyclide/'
    pin.fname = 'orb'
    pin.scale = 1
    pin.cam_dct['location'] = (0, -5, 0)
    pin.cam_dct['lookat'] = (0, 0, 0)
    pin.cam_dct['rotate'] = (20, 0, 0)
    pin.shadow = True
    pin.light_lst = [(1, 0, 0), (0, 1, 0), (0, 0, 1), (-1, 0, 0), (0, -1, 0),
                     (0, 0, -1), (10, 0, 0), (0, 10, 0), (0, 0, 10),
                     (-10, 0, 0), (0, -10, 0), (0, 0, -10)]
    pin.axes_dct['show'] = False
    pin.axes_dct['len'] = 1.2
    pin.height = 400
    pin.width = 800
    pin.quality = 11
    pin.ani_delay = 10

    pin.impl = None

    pin.pmz_dct['A'] = (pmz_AB_lst, 0)
    pin.pmz_dct['B'] = (pmz_AB_lst, 1)
    pin.pmz_dct['C'] = (pmz_CB_lst, 0)

    pin.pmz_dct['FA'] = (pmz_AB_lst, 0)
    pin.pmz_dct['FB'] = (pmz_AB_lst, 1)
    pin.pmz_dct['FC'] = (pmz_CB_lst, 0)

    v0_lst = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 10)]

    v1_lst_A = [(sage_QQ(i) / 180) * sage_pi for i in range(180, 360, 10)]
    v1_lst_B = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 180, 10)]
    v1_lst_C = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 180, 10)]

    v1_lst_FA = [(sage_QQ(i) / 180) * sage_pi for i in range(180, 360, 2)]
    v1_lst_FB = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 180, 2)]
    v1_lst_FC = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 180, 2)]

    prec = 50

    pin.curve_dct['A'] = {
        'step0': v0_lst,
        'step1': v1_lst_A,
        'prec': prec,
        'width': 0.03
    }
    pin.curve_dct['B'] = {
        'step0': v0_lst,
        'step1': v1_lst_B,
        'prec': prec,
        'width': 0.03
    }
    pin.curve_dct['C'] = {
        'step0': v0_lst,
        'step1': v1_lst_C,
        'prec': prec,
        'width': 0.03
    }

    pin.curve_dct['FA'] = {
        'step0': v0_lst,
        'step1': v1_lst_FA,
        'prec': prec,
        'width': 0.02
    }
    pin.curve_dct['FB'] = {
        'step0': v0_lst,
        'step1': v1_lst_FB,
        'prec': prec,
        'width': 0.02
    }
    pin.curve_dct['FC'] = {
        'step0': v0_lst,
        'step1': v1_lst_FC,
        'prec': prec,
        'width': 0.02
    }

    col_A = (0.6, 0.4, 0.1, 0.0)
    col_B = (0.1, 0.15, 0.0, 0.0)
    col_C = (0.2, 0.3, 0.2, 0.0)
    colFF = (0.1, 0.1, 0.1, 0.0)

    pin.text_dct['A'] = [True, col_A, 'phong 0.2 phong_size 5']
    pin.text_dct['B'] = [True, col_B, 'phong 0.2 phong_size 5']
    pin.text_dct['C'] = [True, col_C, 'phong 0.2 phong_size 5']
    pin.text_dct['FA'] = [True, colFF, 'phong 0.2 phong_size 5']
    pin.text_dct['FB'] = [True, colFF, 'phong 0.2 phong_size 5']
    pin.text_dct['FC'] = [True, colFF, 'phong 0.2 phong_size 5']

    # raytrace image/animation
    create_pov(pin, ['A', 'B', 'C'])
    create_pov(pin, ['A', 'B', 'C', 'FA', 'FB', 'FC'])
    create_pov(pin, ['A', 'B', 'FA', 'FB'])
    create_pov(pin, ['B', 'C', 'FA', 'FB'])
Ejemplo n.º 15
0
    def test__get_trn_S3(self):

        R = sage_PolynomialRing(sage_QQ,
                                't0,t1,t2,t3,x0,x1,x2,x3,x4,y0,y1,y2,y3,y4')
        t0, t1, t2, t3, x0, x1, x2, x3, x4, y0, y1, y2, y3, y4 = R.gens()

        #
        # We obtain p:S^3 ---> S^3 by composing
        # stereographic projection S^3--->P^3, x |---> (x0-x4:x1:x2:x3)
        # translation P^3--->P^3, and
        # inverse stereographic projection P^3--->S^3.
        #
        z0 = t0 * (x0 - x4)
        z1 = t0 * x1 + t1 * (x0 - x4)
        z2 = t0 * x2 + t2 * (x0 - x4)
        z3 = t0 * x3 + t3 * (x0 - x4)
        ZZ = z1**2 + z2**2 + z3**2
        p = [z0**2 + ZZ, 2 * z0 * z1, 2 * z0 * z2, 2 * z0 * z3, -z0**2 + ZZ]
        #
        # We look at the coefficients of p with the following code
        #
        # for i in [0, 1, 2, 3, 4]:
        #     print '\np[', i, ']'
        #     for cf in [t0 ** 2, t1 ** 2, t2 ** 2, t3 ** 2, t0 * t1, t0 * t2, t0 * t3, t1 * t2, t1 * t3, t2 * t3 ]:
        #         pcf = p[i].coefficient( cf )
        #         if pcf == 0: continue
        #         pcf = sage_factor( pcf )
        #         print( cf, ':', pcf )
        #
        # this leads to the following output
        #
        # p[ 0 ]
        # (t0^2, ':', x0^2 + x1^2 + x2^2 + x3^2 - 2*x0*x4 + x4^2)
        # (t1^2, ':', (x0 - x4)^2)
        # (t2^2, ':', (x0 - x4)^2)
        # (t3^2, ':', (x0 - x4)^2)
        # (t0*t1, ':', (2) * x1 * (x0 - x4))
        # (t0*t2, ':', (2) * x2 * (x0 - x4))
        # (t0*t3, ':', (2) * x3 * (x0 - x4))
        #
        # p[ 1 ]
        # (t0^2, ':', (2) * x1 * (x0 - x4))
        # (t0*t1, ':', (2) * (x0 - x4)^2)
        #
        # p[ 2 ]
        # (t0^2, ':', (2) * x2 * (x0 - x4))
        # (t0*t2, ':', (2) * (x0 - x4)^2)
        #
        # p[ 3 ]
        # (t0^2, ':', (2) * x3 * (x0 - x4))
        # (t0*t3, ':', (2) * (x0 - x4)^2)
        #
        # p[ 4 ]
        # (t0^2, ':', -x0^2 + x1^2 + x2^2 + x3^2 + 2*x0*x4 - x4^2)
        # (t1^2, ':', (x0 - x4)^2)
        # (t2^2, ':', (x0 - x4)^2)
        # (t3^2, ':', (x0 - x4)^2)
        # (t0*t1, ':', (2) * x1 * (x0 - x4))
        # (t0*t2, ':', (2) * x2 * (x0 - x4))
        # (t0*t3, ':', (2) * x3 * (x0 - x4))
        #

        #
        # We use -x0^2+x1^2+x2^2+x3^2+x4^2==0
        # to simplify the coefficients so that we
        # obtain the map q:S^3--->S^3.
        #
        TT = (sage_QQ(1) / 2) * (t1**2 + t2**2 + t3**2)
        XT = x1 * t1 + x2 * t2 + x3 * t3
        q = [
            x0 + (x0 - x4) * TT + XT, x1 + (x0 - x4) * t1, x2 + (x0 - x4) * t2,
            x3 + (x0 - x4) * t3, x4 + (x0 - x4) * TT + XT
        ]

        #
        # Obtain 5x5 matrix Mq of linear transformation q.
        #
        mat = []
        for i in [0, 1, 2, 3, 4]:
            row = []
            for cf in [x0, x1, x2, x3, x4]:
                qcf = q[i].coefficient(cf)
                row += [qcf]
            mat += [row]
        Mq = sage_matrix(mat)
        T = get_trn_S3([t1, t2, t3])
        print(Mq)
        assert Mq == T

        #
        # Check how the map acts on P^3
        #
        YY = y1**2 + y2**2 + y3**2
        u = Mq * sage_vector(
            [y0**2 + YY, 2 * y0 * y1, 2 * y0 * y2, 2 * y0 * y3, -y0**2 + YY])
        u = [u[0] - u[4], u[1], u[2], u[3]]
        assert '[2*y0^2, 2*t1*y0^2 + 2*y0*y1, 2*t2*y0^2 + 2*y0*y2, 2*t3*y0^2 + 2*y0*y3]' == str(
            u)

        #
        # Some additional sanity checks
        #
        Q = T.subs({t1: 1, t2: 2, t3: 5})
        v = Q * sage_vector([1, 0, 0, 0, -1])
        assert -v[0]**2 + v[1]**2 + v[2]**2 + v[3]**2 + v[4]**2 == 0
        assert Q * sage_vector([1, 0, 0, 0, 1]) == sage_vector([1, 0, 0, 0, 1])
Ejemplo n.º 16
0
def quadric_smooth():
    '''
    Construct povray image of rulings on hyperboloid of one sheet.
    '''

    # construct the two rulings on the hyperboloid
    # by rotating lines L1 and L2
    c0, s0, c1, s1, t0 = OrbRing.coerce('c0,s0,c1,s1,t0')
    P = sage_vector([-2, -1, -0.5])
    Q = sage_vector([2, -1, -0.5])
    L0 = t0 * P + (t0 - 1) * Q
    L1 = t0 * Q + (t0 - 1) * P
    M = sage_matrix([(c1, s1, 0), (-s1, c1, 0), (0, 0, 1)])
    pmz_A_lst = [1] + list(M * L0)
    pmz_B_lst = [1] + list(M * L1)

    OrbTools.p('pmz_A_lst =', pmz_A_lst)
    for pmz in pmz_A_lst:
        OrbTools.p('\t\t', pmz)

    OrbTools.p('pmz_B_lst =', pmz_B_lst)
    for pmz in pmz_B_lst:
        OrbTools.p('\t\t', pmz)

    # PovInput ring cyclide
    #
    pin = PovInput()

    pin.path = './' + get_time_str() + '_quadric_smooth/'
    pin.fname = 'orb'
    pin.scale = 1
    pin.cam_dct['location'] = (0, -10, 0)
    pin.cam_dct['lookat'] = (0, 0, 0)
    pin.cam_dct['rotate'] = (0, 0, 0)
    pin.shadow = True
    pin.light_lst = [(0, 0, -5), (0, -5, 0), (-5, 0, 0), (0, 0, 5), (0, 5, 0),
                     (5, 0, 0)]
    pin.axes_dct['show'] = False
    pin.axes_dct['len'] = 1.2

    pin.width = 400
    pin.height = 800
    pin.quality = 11
    pin.ani_delay = 10

    pin.impl = None

    pin.pmz_dct['A'] = (pmz_A_lst, 0)
    pin.pmz_dct['B'] = (pmz_B_lst, 0)
    pin.pmz_dct['FA'] = (pmz_A_lst, 0)
    pin.pmz_dct['FB'] = (pmz_B_lst, 0)

    v0_lst = [sage_QQ(i) / 10 for i in range(-15, 30, 5)]  # -15, 35
    v1_lst = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 36)]
    v1_lst_F = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 2)]

    pin.curve_dct['A'] = {
        'step0': v0_lst,
        'step1': v1_lst,
        'prec': 10,
        'width': 0.1
    }
    pin.curve_dct['B'] = {
        'step0': v0_lst,
        'step1': v1_lst,
        'prec': 10,
        'width': 0.1
    }
    pin.curve_dct['FA'] = {
        'step0': v0_lst,
        'step1': v1_lst_F,
        'prec': 10,
        'width': 0.01
    }
    pin.curve_dct['FB'] = {
        'step0': v0_lst,
        'step1': v1_lst_F,
        'prec': 10,
        'width': 0.01
    }

    col_A = (0.5, 0.0, 0.0, 0.0)  # red
    col_B = rgbt2pov((28, 125, 154, 0))  # blue

    pin.text_dct['A'] = [True, col_A, 'phong 0.2 phong_size 5']
    pin.text_dct['B'] = [True, col_B, 'phong 0.2 phong_size 5']
    pin.text_dct['FA'] = [True, (0.1, 0.1, 0.1, 0.0), 'phong 0.2 phong_size 5']
    pin.text_dct['FB'] = [True, (0.1, 0.1, 0.1, 0.0), 'phong 0.2 phong_size 5']

    # raytrace image/animation
    create_pov(pin, ['A', 'B', 'FA', 'FB'])
Ejemplo n.º 17
0
    def test__get_scale_S3(self):

        R = sage_PolynomialRing(sage_QQ, 's,t,x0,x1,x2,x3,x4,y0,y1,y2,y3,y4')
        s, t, x0, x1, x2, x3, x4, y0, y1, y2, y3, y4 = R.gens()

        z0 = t * (x0 - x4)
        z1 = s * x1
        z2 = s * x2
        z3 = s * x3
        ZZ = z1**2 + z2**2 + z3**2
        p = [z0**2 + ZZ, 2 * z0 * z1, 2 * z0 * z2, 2 * z0 * z3, -z0**2 + ZZ]
        #
        # We look at the coefficients of p with the following code
        #
        # for i in [0, 1, 2, 3, 4]:
        #     print '\np[', i, ']'
        #     for cf in [s ** 2, s * t, t ** 2]:
        #         pcf = p[i].coefficient( cf )
        #         if pcf == 0: continue
        #         pcf = sage_factor( pcf )
        #         print( cf, ':', pcf )
        #
        # this leads to the following output
        #
        # p[ 0 ]
        # (s^2, ':', x1^2 + x2^2 + x3^2)
        # (t^2, ':', (x0 - x4)^2)
        #
        # p[ 1 ]
        # (s*t, ':', (2) * x1 * (x0 - x4))
        #
        # p[ 2 ]
        # (s*t, ':', (2) * x2 * (x0 - x4))
        #
        # p[ 3 ]
        # (s*t, ':', (2) * x3 * (x0 - x4))
        #
        # p[ 4 ]
        # (s^2, ':', x1^2 + x2^2 + x3^2)
        # (t^2, ':', (-1) * (x0 - x4)^2)

        #
        # We use -x0^2+x1^2+x2^2+x3^2+x4^2==0
        # to simplify the coefficients so that we
        # obtain the map q:S^3--->S^3. We set t=1.
        #
        q = [(x0 + x4) * s**2 + (x0 - x4), 2 * x1 * s, 2 * x2 * s, 2 * x3 * s,
             (x0 + x4) * s**2 - (x0 - x4)]

        #
        # Obtain 5x5 matrix Mq of linear transformation q.
        #
        Mq = []
        for i in [0, 1, 2, 3, 4]:
            row = []
            for cf in [x0, x1, x2, x3, x4]:
                qcf = q[i].coefficient(cf)
                row += [qcf]
            Mq += [row]
        Mq = sage_matrix(Mq)
        S = get_scale_S3(s)
        print(Mq)
        assert Mq == S

        #
        # Check how the map acts on P^3
        #
        YY = y1**2 + y2**2 + y3**2
        u = Mq * sage_vector(
            [y0**2 + YY, 2 * y0 * y1, 2 * y0 * y2, 2 * y0 * y3, -y0**2 + YY])
        u = [u[0] - u[4], u[1], u[2], u[3]]
        assert '[4*y0^2, 4*s*y0*y1, 4*s*y0*y2, 4*s*y0*y3]' == str(u)

        #
        # Some additional sanity checks
        #
        Q = S.subs({s: 2})
        v = Q * sage_vector([1, 0, 1, 0, 0])
        w = Q * sage_vector([1, 0, 0, 0, 1])
        assert -v[0]**2 + v[1]**2 + v[2]**2 + v[3]**2 + v[4]**2 == 0
        assert list(w) == [8, 0, 0, 0, 8]
Ejemplo n.º 18
0
def perseus_cyclide():
    '''
    Creates povray image of the Perseus cyclide.
    '''

    # We first construct a trigonometric parametrization
    # by rotating a circle.
    #     cos(pi/3) = 1/2
    #     sin(pi/3) = sqrt(3)/2
    #
    r, R = 1, 2
    c0, s0, c1, s1 = sage_var('c0,s0,c1,s1')
    x, y, v, w, a0 = sage_var('x,y,v,w,a0')
    q2 = sage_QQ(1) / 2
    MZ = sage_matrix([(c1, s1, 0), (-s1, c1, 0), (0, 0, 1)])
    MZc = MZ.subs({c1: q2, s1: q2 * a0})
    V = sage_vector([r * c0, 0, r * s0])
    V = MZc * V
    V[0] = V[0] + R
    pmz_AB_lst = list(MZ * V)

    OrbTools.p('V =', V)
    OrbTools.p('pmz_AB_lst =', pmz_AB_lst)
    for pmz in pmz_AB_lst:
        OrbTools.p('\t\t', sage_factor(pmz))

    # We convert the trigonometric parametrization to a
    # rational parametrization, via the following formulas:
    #
    #     cos(s) = (y^2-x^2) / (y^2+x^2)
    #     sin(s) = 2*x*y / (y^2+x^2)
    #     y=1; x = arctan( s/2 )
    #
    C0 = (y**2 - x**2) / (y**2 + x**2)
    S0 = 2 * x * y / (y**2 + x**2)
    C1 = (w**2 - v**2) / (w**2 + v**2)
    S1 = 2 * v * w / (w**2 + v**2)
    den = (y**2 + x**2) * (w**2 + v**2)
    dct = {c0: C0, s0: S0, c1: C1, s1: S1}
    pmz_lst = [den] + [(elt.subs(dct) * den).simplify_full()
                       for elt in list(MZ * V)]
    OrbTools.p('pmz_lst =', pmz_lst)
    for pmz in pmz_lst:
        OrbTools.p('\t\t', sage_factor(pmz))

    # do a basepoint analysis on the rational parametrization
    #
    ring = PolyRing('x,y,v,w', True).ext_num_field('t^2-3')
    ls = LinearSeries([str(pmz) for pmz in pmz_lst], ring)
    OrbTools.p(ls.get_bp_tree())

    # construct linear series for families of conics
    #
    ring = PolyRing(
        'x,y,v,w')  # construct polynomial ring over new ground field
    OrbTools.p(ring)
    x, y, v, w = ring.gens()
    a0, a1, a2, a3 = ring.root_gens()

    p1 = ['xv', (-a3, a1)]
    p2 = ['xv', (-a2, -a1)]
    p3 = ['xv', (a3, a1)]
    p4 = ['xv', (a2, -a1)]

    bpt_1234 = BasePointTree(['xv', 'xw', 'yv', 'yw'])
    bpt_1234.add(p1[0], p1[1], 1)
    bpt_1234.add(p2[0], p2[1], 1)
    bpt_1234.add(p3[0], p3[1], 1)
    bpt_1234.add(p4[0], p4[1], 1)

    bpt_12 = BasePointTree(['xv', 'xw', 'yv', 'yw'])
    bpt_12.add(p1[0], p1[1], 1)
    bpt_12.add(p2[0], p2[1], 1)

    bpt_34 = BasePointTree(['xv', 'xw', 'yv', 'yw'])
    bpt_34.add(p3[0], p3[1], 1)
    bpt_34.add(p4[0], p4[1], 1)

    ls_22 = LinearSeries.get([2, 2], bpt_1234)
    ls_21 = LinearSeries.get([2, 1], bpt_1234)
    ls_12 = LinearSeries.get([1, 2], bpt_1234)
    ls_11a = LinearSeries.get([1, 1], bpt_12)
    ls_11b = LinearSeries.get([1, 1], bpt_34)

    OrbTools.p('linear series 22 =\n', ls_22)
    OrbTools.p('linear series 21 =\n', ls_21)
    OrbTools.p('linear series 12 =\n', ls_12)
    OrbTools.p('linear series 11a =\n', ls_11a)
    OrbTools.p('linear series 11b =\n', ls_11b)

    # compute reparametrization from the linear series of families
    ring = PolyRing('x,y,v,w,c0,s0,c1,s1')
    OrbTools.p(ring)
    x, y, v, w, c0, s0, c1, s1 = ring.gens()
    a0, a1, a2, a3 = ring.root_gens()
    pmz_AB_lst = [1] + ring.coerce(pmz_AB_lst)
    pmz_lst = ring.coerce(pmz_lst)

    q2 = sage_QQ(1) / 2
    a = 2 * a0 / 3
    b = (-a0 * a1 / 3 - q2) * a3
    c = (a0 * a1 / 3 - q2) * a2
    d = (a1 / 2 - a0 / 3) * a3
    e = (-a1 / 2 - a0 / 3) * a2
    bc = b + c
    de = d + e

    X = 1 - s0
    Y = c0
    V = 1 - s1
    W = c1
    CB_dct = {
        x: X,
        y: Y,
        v: W * X + bc * W * Y - de * V * Y,
        w: V * X + bc * V * Y + de * W * Y
    }
    DB_dct = {
        x: X,
        y: Y,
        v: W * X - bc * W * Y + de * V * Y,
        w: V * X - bc * V * Y - de * W * Y
    }
    EB_dct = {
        x: X,
        y: Y,
        v: W * X**2 + W * Y**2 - a * V * Y**2,
        w: V * X**2 + V * Y**2 + a * W * Y**2
    }
    pmz_CB_lst = [pmz.subs(CB_dct) for pmz in pmz_lst]  # CB  11a
    pmz_DB_lst = [pmz.subs(DB_dct) for pmz in pmz_lst]  # CB  11b
    pmz_EB_lst = [pmz.subs(EB_dct) for pmz in pmz_lst]  # CB  21

    # output
    OrbTools.p('pmz_AB_lst =\n', pmz_AB_lst)
    OrbTools.p('pmz_CB_lst =\n', pmz_CB_lst)
    OrbTools.p('pmz_DB_lst =\n', pmz_DB_lst)
    OrbTools.p('pmz_EB_lst =\n', pmz_EB_lst)

    # approximate by map defined over rational numbers
    ci_idx = 5  # index defining the complex embedding
    pmz_AB_lst = OrbRing.approx_QQ_pol_lst(pmz_AB_lst, ci_idx)
    pmz_CB_lst = OrbRing.approx_QQ_pol_lst(pmz_CB_lst, ci_idx)
    pmz_DB_lst = OrbRing.approx_QQ_pol_lst(pmz_DB_lst, ci_idx)
    pmz_EB_lst = OrbRing.approx_QQ_pol_lst(pmz_EB_lst, ci_idx)

    # mathematica input
    ms = ''
    for pmz, AB in [(pmz_lst, 'ZZ'), (pmz_AB_lst, 'AB'), (pmz_CB_lst, 'CB'),
                    (pmz_DB_lst, 'DB'), (pmz_EB_lst, 'EB')]:
        s = 'pmz' + AB + '=' + str(pmz) + ';'
        s = s.replace('[', '{').replace(']', '}')
        ms += '\n' + s
    OrbTools.p('Mathematica input =', ms)

    # PovInput ring cyclide
    #
    pin = PovInput()

    pin.path = './' + get_time_str() + '_perseus_cyclide/'
    pin.fname = 'orb'
    pin.scale = 1
    pin.cam_dct['location'] = (0, 7, 0)
    pin.cam_dct['lookat'] = (0, 0, 0)
    pin.cam_dct['rotate'] = (45, 0, 0)
    pin.shadow = True
    pin.light_lst = [(0, 0, -10), (0, -10, 0), (-10, 0, 0), (0, 0, 10),
                     (0, 10, 0), (10, 0, 0)]
    pin.axes_dct['show'] = False
    pin.axes_dct['len'] = 1.2
    pin.height = 400
    pin.width = 800
    pin.quality = 11
    pin.ani_delay = 10

    pin.impl = None

    pin.pmz_dct['A'] = (pmz_AB_lst, 0)
    pin.pmz_dct['B'] = (pmz_AB_lst, 1)
    pin.pmz_dct['C'] = (pmz_CB_lst, 0)
    pin.pmz_dct['D'] = (pmz_DB_lst, 0)
    pin.pmz_dct['E'] = (pmz_EB_lst, 0)

    pin.pmz_dct['FA'] = (pmz_AB_lst, 0)
    pin.pmz_dct['FB'] = (pmz_AB_lst, 1)
    pin.pmz_dct['FC'] = (pmz_CB_lst, 0)
    pin.pmz_dct['FD'] = (pmz_DB_lst, 0)
    pin.pmz_dct['FE'] = (pmz_EB_lst, 0)

    v0_lst = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 10)]
    v1_lst_A = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 10)]  # 5
    v1_lst_B = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 15)]
    v1_lst_C = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 36)]
    v1_lst_D = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 36)]
    v1_lst_E = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 10)]  # 5

    v1_lst_F = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 1)]

    prec = 50

    pin.curve_dct['A'] = {
        'step0': v0_lst,
        'step1': v1_lst_A,
        'prec': prec,
        'width': 0.04
    }
    pin.curve_dct['B'] = {
        'step0': v0_lst,
        'step1': v1_lst_B,
        'prec': prec,
        'width': 0.04
    }
    pin.curve_dct['C'] = {
        'step0': v0_lst,
        'step1': v1_lst_C,
        'prec': prec,
        'width': 0.05
    }
    pin.curve_dct['D'] = {
        'step0': v0_lst,
        'step1': v1_lst_D,
        'prec': prec,
        'width': 0.05
    }
    pin.curve_dct['E'] = {
        'step0': v0_lst,
        'step1': v1_lst_E,
        'prec': prec,
        'width': 0.04
    }

    pin.curve_dct['FA'] = {
        'step0': v0_lst,
        'step1': v1_lst_F,
        'prec': prec,
        'width': 0.01
    }
    pin.curve_dct['FB'] = {
        'step0': v0_lst,
        'step1': v1_lst_F,
        'prec': prec,
        'width': 0.01
    }
    pin.curve_dct['FC'] = {
        'step0': v0_lst,
        'step1': v1_lst_F,
        'prec': prec,
        'width': 0.01
    }
    pin.curve_dct['FD'] = {
        'step0': v0_lst,
        'step1': v1_lst_F,
        'prec': prec,
        'width': 0.01
    }
    pin.curve_dct['FE'] = {
        'step0': v0_lst,
        'step1': v1_lst_F,
        'prec': prec,
        'width': 0.01
    }

    col_A = (0.6, 0.0, 0.0, 0.0)  # red
    col_B = (0.8, 0.6, 0.2, 0.0)  # beige
    col_C = (0.6, 0.0, 0.0, 0.0
             )  # red   *** rgbt2pov( ( 74, 33, 0, 0 ) )     # brown
    col_D = (0.2, 0.6, 0.0, 0.0
             )  # green *** rgbt2pov( ( 28, 125, 154, 0 ) )  # blue
    col_E = (0.2, 0.6, 0.0, 0.0)  # green
    colFF = (0.1, 0.1, 0.1, 0.0)

    pin.text_dct['A'] = [True, col_A, 'phong 0.2 phong_size 5']
    pin.text_dct['B'] = [True, col_B, 'phong 0.2 phong_size 5']
    pin.text_dct['C'] = [True, col_C, 'phong 0.2 phong_size 5']
    pin.text_dct['D'] = [True, col_D, 'phong 0.2 phong_size 5']
    pin.text_dct['E'] = [True, col_E, 'phong 0.2 phong_size 5']

    pin.text_dct['FA'] = [True, colFF, 'phong 0.2 phong_size 5']
    pin.text_dct['FB'] = [True, colFF, 'phong 0.2 phong_size 5']
    pin.text_dct['FC'] = [True, colFF, 'phong 0.2 phong_size 5']
    pin.text_dct['FD'] = [True, colFF, 'phong 0.2 phong_size 5']
    pin.text_dct['FE'] = [True, colFF, 'phong 0.2 phong_size 5']

    # raytrace image/animation
    create_pov(pin, ['C', 'D', 'FC', 'FD'])
    create_pov(pin, ['A', 'B', 'FC', 'FD'])
    create_pov(pin, ['E', 'B', 'FC', 'FD'])
Ejemplo n.º 19
0
def blum_cyclide():
    '''
    Construct a povray image of 6 families of circles on a smooth Darboux cyclide.
    This surface is also known as the Blum cyclide.
    '''

    # construct dct
    a0 = PolyRing( 'x,y,v,w', True ).ext_num_field( 't^2 + 1' ).root_gens()[0]  # i

    bpt_1234 = BasePointTree( ['xv', 'xw', 'yv', 'yw'] )
    bpt_1234.add( 'xv', ( -1 * a0, 1 * a0 ), 1 )  # e1
    bpt_1234.add( 'xv', ( 1 * a0, -1 * a0 ), 1 )  # e2
    bpt_1234.add( 'xw', ( -2 * a0, 2 * a0 ), 1 )  # e3
    bpt_1234.add( 'xw', ( 2 * a0, -2 * a0 ), 1 )  # e4

    bpt_12 = BasePointTree( ['xv', 'xw', 'yv', 'yw'] )
    bpt_12.add( 'xv', ( -1 * a0, 1 * a0 ), 1 )  # e1
    bpt_12.add( 'xv', ( 1 * a0, -1 * a0 ), 1 )  # e2

    bpt_34 = BasePointTree( ['xv', 'xw', 'yv', 'yw'] )
    bpt_34.add( 'xw', ( -2 * a0, 2 * a0 ), 1 )  # e3
    bpt_34.add( 'xw', ( 2 * a0, -2 * a0 ), 1 )  # e4

    ls_22 = LinearSeries.get( [2, 2], bpt_1234 )  # |2(l1+l2)-e1-e2-e3-e4|
    ls_21 = LinearSeries.get( [2, 1], bpt_1234 )
    ls_12 = LinearSeries.get( [1, 2], bpt_1234 )
    ls_11a = LinearSeries.get( [1, 1], bpt_12 )
    ls_11b = LinearSeries.get( [1, 1], bpt_34 )

    OrbTools.p( 'linear series 22 =\n', ls_22 )
    OrbTools.p( 'linear series 21 =\n', ls_21 )
    OrbTools.p( 'linear series 12 =\n', ls_12 )
    OrbTools.p( 'linear series 11a =\n', ls_11a )
    OrbTools.p( 'linear series 11b =\n', ls_11b )

    sig = ( 4, 1 )
    pol_lst = ls_22.get_implicit_image()

    # determine signature
    x_lst = sage_PolynomialRing( sage_QQ, [ 'x' + str( i ) for i in range( sum( sig ) )] ).gens()
    for pol in pol_lst:

        if pol.degree() == 2:
            M = sage_invariant_theory.quadratic_form( pol, x_lst ).as_QuadraticForm().matrix()
            D, V = sage_matrix( sage_QQ, M ).eigenmatrix_right()  # D has first all negative values on diagonal
            cur_sig = ( len( [ d for d in D.diagonal() if d < 0 ] ), len( [ d for d in D.diagonal() if d > 0 ] ) )
        else:
            cur_sig = '[no signature]'
        OrbTools.p( '\t\t', pol, cur_sig )

    # obtain surface in sphere
    coef_lst = [0, -1, -1]
    dct = get_surf( ls_22, sig, coef_lst )

    # construct projection matrix P
    U, J = dct['UJ']
    U.swap_rows( 0, 4 )
    J.swap_columns( 0, 4 )
    J.swap_rows( 0, 4 )
    assert dct['M'] == approx_QQ( U.T * J * U )
    approxU = approx_QQ( U )
    P = sage_identity_matrix( 5 ).submatrix( 0, 0, 4, 5 )
    P[0, 4] = -1;
    P = P * approxU
    OrbTools.p( ' approx_QQ( U ) =', list( approx_QQ( U ) ) )
    OrbTools.p( ' approx_QQ( J ) =', list( approx_QQ( J ) ) )
    OrbTools.p( ' P              =', list( P ) )

    # call get_proj
    f_xyz, pmz_AB_lst = get_proj( dct['imp_lst'], dct['pmz_lst'], P )
    f_xyz_deg_lst = [f_xyz.degree( sage_var( v ) ) for v in ['x', 'y', 'z']]

    # compute reparametrization
    ring = PolyRing( 'x,y,v,w,c0,s0,c1,s1' )  # construct polynomial ring with new generators
    p_lst = ring.coerce( ls_22.pol_lst )
    x, y, v, w, c0, s0, c1, s1 = ring.gens()
    X = 1 - s0; Y = c0;  # see get_S1xS1_pmz()
    V = 1 - s1; W = c1;
    CB_dct = { x:X, y:Y, v:X * W + Y * V, w: X * V - Y * W }
    DB_dct = { x:X, y:Y, v:4 * X * W - Y * V, w: X * V + Y * W }
    EB_dct = { x:X, y:Y, v:40 * W * X ** 2 + 25 * W * Y ** 2 + 24 * V * X * Y, w:40 * V * X ** 2 + 16 * V * Y ** 2 - 15 * W * X * Y  }
    AF_dct = { x:-10 * Y * V ** 2 - 25 * Y * W ** 2 + 9 * X * V * W, y:15 * X * V ** 2 + 24 * X * W ** 2 - 15 * Y * V * W, v:V, w:W  }
    pmz_CB_lst = list( P * sage_vector( [ p.subs( CB_dct ) for p in p_lst] ) )
    pmz_DB_lst = list( P * sage_vector( [ p.subs( DB_dct ) for p in p_lst] ) )
    pmz_EB_lst = list( P * sage_vector( [ p.subs( EB_dct ) for p in p_lst] ) )
    pmz_AF_lst = list( P * sage_vector( [ p.subs( AF_dct ) for p in p_lst] ) )


    # output
    OrbTools.p( 'f_xyz =', f_xyz_deg_lst, '\n', f_xyz )
    OrbTools.p( 'pmz_AB_lst =\n', pmz_AB_lst )
    OrbTools.p( 'pmz_CB_lst =\n', pmz_CB_lst )
    OrbTools.p( 'pmz_DB_lst =\n', pmz_DB_lst )
    OrbTools.p( 'pmz_EB_lst =\n', pmz_EB_lst )
    OrbTools.p( 'pmz_AF_lst =\n', pmz_AF_lst )

    # mathematica
    pmz_lst = [ ( pmz_AB_lst, 'AB' ),
                ( pmz_CB_lst, 'CB' ),
                ( pmz_DB_lst, 'DB' ),
                ( pmz_EB_lst, 'EB' ),
                ( pmz_AF_lst, 'AF' )]

    OrbTools.p( 'Mathematica input for ParametricPlot3D:' )
    for pmz, AB in pmz_lst:
        s = 'pmz' + AB + '=' + str( pmz )
        s = s.replace( '[', '{' ).replace( ']', '}' )
        print( s )

    # PovInput for Blum cyclide
    #
    pin = PovInput()
    pin.path = './' + get_time_str() + '_blum_cyclide/'
    pin.fname = 'orb'
    pin.scale = 1
    pin.cam_dct['location'] = ( 0, -7, 0 )
    pin.cam_dct['lookat'] = ( 0, 0, 0 )
    pin.cam_dct['rotate'] = ( 20, 180, 20 )
    pin.shadow = True
    pin.light_lst = [( 0, 0, -5 ), ( 0, -5, 0 ), ( -5, 0, 0 ),
                     ( 0, 0, 5 ), ( 0, 5, 0 ), ( 5, 0, 0 ),
                     ( -5, -5, -5 ), ( 5, -5, 5 ), ( -5, -5, 5 ), ( 5, -5, -5 ) ]
    pin.axes_dct['show'] = False
    pin.axes_dct['len'] = 1.2
    pin.height = 400
    pin.width = 800
    pin.quality = 11
    pin.ani_delay = 10
    pin.impl = None

    start0 = sage_QQ( 1 ) / 10  # step0=10 step1=15
    v0_lst = [ start0 + ( sage_QQ( i ) / 180 ) * sage_pi for i in range( 0, 360, 10 )]
    v1_lst = [ ( sage_QQ( i ) / 180 ) * sage_pi for i in range( 0, 360, 15 )]
    v1_lst_F = [ start0 + ( sage_QQ( i ) / 360 ) * sage_pi for i in range( 0, 720, 1 )]

    v1_lst_WE = [1.8, 2.3, 2.7, 3.1, 3.5, 3.8, 4.134, 4.31, 4.532, 4.7, 4.9, 5.08, 5.25, 5.405, 5.553, 5.7, 5.84]
    v1_lst_WF = [1.69, 1.87, 2.07, 2.26, 2.5, 2.72, 2.96, 3.2, 3.42, 3.65, 3.81]
    v1_lst_WD = [ 5.44, 5.56, 5.68, 5.81, 5.95, 6.1, 6.27, 6.474]  # [5.01, 5.12, 5.22, 5.32,

    v1_lst_SA = [6.5]; v1_lst_SE = [5.4];
    v1_lst_SB = [5.95]; v1_lst_SF = [2.28];
    v1_lst_SC = [4.83]; v1_lst_SD = [5.55];

    pin.pmz_dct['A'] = ( pmz_AB_lst, 0 )
    pin.pmz_dct['B'] = ( pmz_AB_lst, 1 )
    pin.pmz_dct['C'] = ( pmz_CB_lst, 0 )
    pin.pmz_dct['D'] = ( pmz_DB_lst, 0 )
    pin.pmz_dct['E'] = ( pmz_EB_lst, 0 )
    pin.pmz_dct['F'] = ( pmz_AF_lst, 1 )
    pin.pmz_dct['WD'] = ( pmz_DB_lst, 0 )
    pin.pmz_dct['WE'] = ( pmz_EB_lst, 0 )
    pin.pmz_dct['WF'] = ( pmz_AF_lst, 1 )
    pin.pmz_dct['SA'] = ( pmz_AB_lst, 0 )
    pin.pmz_dct['SB'] = ( pmz_AB_lst, 1 )
    pin.pmz_dct['SC'] = ( pmz_CB_lst, 0 )
    pin.pmz_dct['SD'] = ( pmz_DB_lst, 0 )
    pin.pmz_dct['SE'] = ( pmz_EB_lst, 0 )
    pin.pmz_dct['SF'] = ( pmz_AF_lst, 1 )
    pin.pmz_dct['FA'] = ( pmz_AB_lst, 0 )
    pin.pmz_dct['FB'] = ( pmz_AB_lst, 1 )
    pin.pmz_dct['FC'] = ( pmz_CB_lst, 0 )
    pin.pmz_dct['FD'] = ( pmz_DB_lst, 0 )
    pin.pmz_dct['FE'] = ( pmz_EB_lst, 0 )
    pin.pmz_dct['FF'] = ( pmz_AF_lst, 1 )

    pin.curve_dct['A'] = {'step0':v0_lst, 'step1':v1_lst, 'prec':10, 'width':0.05}
    pin.curve_dct['B'] = {'step0':v0_lst, 'step1':v1_lst, 'prec':10, 'width':0.05}
    pin.curve_dct['C'] = {'step0':v0_lst, 'step1':v1_lst, 'prec':10, 'width':0.05}
    pin.curve_dct['D'] = {'step0':v0_lst, 'step1':v1_lst, 'prec':10, 'width':0.05}
    pin.curve_dct['E'] = {'step0':v0_lst, 'step1':v1_lst, 'prec':10, 'width':0.05}
    pin.curve_dct['F'] = {'step0':v0_lst, 'step1':v1_lst, 'prec':10, 'width':0.05}

    pin.curve_dct['WD'] = {'step0':v0_lst, 'step1':v1_lst_WD, 'prec':10, 'width':0.05}
    pin.curve_dct['WE'] = {'step0':v0_lst, 'step1':v1_lst_WE, 'prec':10, 'width':0.05}
    pin.curve_dct['WF'] = {'step0':v0_lst, 'step1':v1_lst_WF, 'prec':10, 'width':0.05}

    pin.curve_dct['SA'] = {'step0':v0_lst, 'step1':v1_lst_SA, 'prec':10, 'width':0.05}
    pin.curve_dct['SB'] = {'step0':v0_lst, 'step1':v1_lst_SB, 'prec':10, 'width':0.05}
    pin.curve_dct['SC'] = {'step0':v0_lst, 'step1':v1_lst_SC, 'prec':10, 'width':0.05}
    pin.curve_dct['SD'] = {'step0':v0_lst, 'step1':v1_lst_SD, 'prec':10, 'width':0.06}
    pin.curve_dct['SE'] = {'step0':v0_lst, 'step1':v1_lst_SE, 'prec':10, 'width':0.05}
    pin.curve_dct['SF'] = {'step0':v0_lst, 'step1':v1_lst_SF, 'prec':10, 'width':0.05}

    pin.curve_dct['FA'] = {'step0':v0_lst, 'step1':v1_lst_F, 'prec':10, 'width':0.01}
    pin.curve_dct['FB'] = {'step0':v0_lst, 'step1':v1_lst_F, 'prec':10, 'width':0.01}
    pin.curve_dct['FC'] = {'step0':v0_lst, 'step1':v1_lst_F, 'prec':10, 'width':0.01}
    pin.curve_dct['FD'] = {'step0':v0_lst, 'step1':v1_lst_F, 'prec':10, 'width':0.01}
    pin.curve_dct['FE'] = {'step0':v0_lst, 'step1':v1_lst_F, 'prec':10, 'width':0.01}
    pin.curve_dct['FF'] = {'step0':v0_lst, 'step1':v1_lst_F, 'prec':10, 'width':0.01}

    col_A = rgbt2pov( ( 28, 125, 154, 0 ) )  # blue
    col_B = rgbt2pov( ( 74, 33, 0, 0 ) )  # brown
    col_C = rgbt2pov( ( 75, 102, 0, 0 ) )  # green
    col_E = col_A
    col_F = col_B
    col_D = col_C
    colFF = rgbt2pov( ( 179, 200, 217, 0 ) )  # light blue

    pin.text_dct['A'] = [True, col_A, 'phong 0.2' ]
    pin.text_dct['B'] = [True, col_B, 'phong 0.2' ]
    pin.text_dct['C'] = [True, col_C, 'phong 0.2' ]
    pin.text_dct['E'] = [True, col_E, 'phong 0.2' ]
    pin.text_dct['F'] = [True, col_F, 'phong 0.2' ]
    pin.text_dct['D'] = [True, col_D, 'phong 0.2' ]
    pin.text_dct['WE'] = [True, col_E, 'phong 0.2' ]
    pin.text_dct['WF'] = [True, col_F, 'phong 0.2' ]
    pin.text_dct['WD'] = [True, col_D, 'phong 0.2' ]
    pin.text_dct['SA'] = [True, col_A, 'phong 0.2' ]
    pin.text_dct['SB'] = [True, col_B, 'phong 0.2' ]
    pin.text_dct['SC'] = [True, col_C, 'phong 0.2' ]
    pin.text_dct['SE'] = [True, col_E, 'phong 0.2' ]
    pin.text_dct['SF'] = [True, col_F, 'phong 0.2' ]
    pin.text_dct['SD'] = [True, col_D, 'phong 0.2' ]
    pin.text_dct['FA'] = [True, colFF, 'phong 0.2' ]
    pin.text_dct['FB'] = [True, colFF, 'phong 0.2' ]
    pin.text_dct['FC'] = [True, colFF, 'phong 0.2' ]
    pin.text_dct['FE'] = [True, colFF, 'phong 0.2' ]
    pin.text_dct['FF'] = [True, colFF, 'phong 0.2' ]
    pin.text_dct['FD'] = [True, colFF, 'phong 0.2' ]

    # raytrace image/animation
    F_lst = ['FA', 'FB', 'FC']
    S_lst = ['SA', 'SB', 'SC', 'SD', 'SE', 'SF']
    create_pov( pin, ['A', 'B', 'C'] )
    create_pov( pin, ['A', 'B', 'C'] + F_lst )
    create_pov( pin, ['WD', 'WE', 'WF'] )
    create_pov( pin, ['WD', 'WE', 'WF'] + F_lst )
    create_pov( pin, S_lst + F_lst )

    # ABC - EFD
    create_pov( pin, ['A', 'B'] + F_lst )
    create_pov( pin, ['E', 'F'] + F_lst )