예제 #1
0
def horn_cyclide():
    '''
    Creates povray image of horn cyclide. The horn cyclide is 
    an inversion of a circular cone.
    '''

    # Construct a trigonometric parametrization by rotating a circle.
    #
    r = 1; R = sage_QQ( 1 ) / 2;  # 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 horn cyclide
    #
    pin = PovInput()

    pin.path = './' + get_time_str() + '_horn_cyclide/'
    pin.fname = 'orb'
    pin.scale = 1
    pin.cam_dct['location'] = ( 0, -4, 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, 2 )]
    v1_lstFB = [ ( sage_QQ( i ) / 180 ) * sage_pi for i in range( 0, 180, 2 )]

    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'] )
예제 #2
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'])
예제 #3
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'])
예제 #4
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'])
예제 #5
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'])