Ejemplo n.º 1
0
def make_map( filename ):

    def _sphere_to_cart( theta, phi ):
        return vector_3d( \
            s.sin( theta ) * s.cos( phi ), \
            s.cos( theta ), \
            s.sin( theta ) * s.sin( phi ) )

    def _draw_this_circle( c, Circle ):
        pass
    
    def _draw_latitude_circle( c, latitude ):    
        pass
    
    def _draw_longitude_circle( c, longitude ):
        pass


    # set up our triangle
    c = get_letter_canvas( filename )

    # hex grid
    c.setStrokeColor( (0.75, 0.75, 1) )
    # c.setLineWidth( 0.001 )
    # draw_hexes( c, 2 )
    c.setLineWidth( 0.0005 )
    draw_hexes( c, 10 )

    c.setStrokeColor( (0.75,0.75,0.75) )
    d20 = Icosahedron( numeric = True )
    d20.rotate_vertices( rot_x( -s.atan2( s.GoldenRatio-1, s.GoldenRatio ).evalf() ) )
    d20.make_faces()
    mappings = face_mappings( d20 )

    face_plane = d20.faces[0].plane
    rot_mat = mappings.face_dict['a'][0]
 
    for lat in range( 0, 40, 5 ):
        if lat % 5:
            c.setLineWidth( 0.0005 )
        else:
            c.setLineWidth( 0.001 )

        lat_rad = to_rad( lat ).evalf()
        try:
            point = line_plane_intersect( two_point_line( zero_3d, _sphere_to_cart( lat_rad, 0 ) ), face_plane )
            mp1 = point.multiply( rot_mat )
            point = line_plane_intersect( two_point_line( zero_3d, _sphere_to_cart( lat_rad, _pi/2 ) ), face_plane )
            mp2 = point.multiply( rot_mat )
            point = line_plane_intersect( two_point_line( zero_3d, _sphere_to_cart( lat_rad, -_pi/2 ) ), face_plane )
            mp3 = point.multiply( rot_mat )
            
            the_circle = three_point_circle( mp1[0], mp1[1], mp2[0], mp2[1], mp3[0], mp3[1] )
            c.circle( the_circle.x0, the_circle.y0, the_circle.radius, fill=0, stroke=1 )
            
        except:
            pass
  
    for lon in range( 0, 360, 5 ):
    
        if lon % 5:
            c.setLineWidth( 0.0005 )
        else:
            c.setLineWidth( 0.001 )
        
        try:
            point = line_plane_intersect( two_point_line( _sphere_to_cart( _pi/4, to_rad( lon).evalf() ), zero_3d ), face_plane )
            mp1 = point.multiply( rot_mat )
            
            end_pt = _pi/9
            if (lon % 5) == 0:
                end_pt = _pi/18
            if (lon % 10) == 0:
                end_pt = _pi/36
            if (lon % 30) == 0:
                end_pt = 0
            
            point = line_plane_intersect( two_point_line( _sphere_to_cart( end_pt, to_rad( lon).evalf() ), zero_3d ), face_plane )
            mp2 = point.multiply( rot_mat )
            c.line( mp1[0], mp1[1], mp2[0], mp2[1] )
            
        except:
            pass
            
        


    c.showPage()
    c.save()
Ejemplo n.º 2
0
def make_map( filename ):

    def _sphere_to_cart( theta, phi ):
        return vector_3d( \
            s.sin( theta ) * s.cos( phi ), \
            s.cos( theta ), \
            s.sin( theta ) * s.sin( phi ) )

    def _draw_this_circle( c, Circle ):
        pass
    
    def _draw_latitude_circle( c, latitude ):    
        pass
    
    def _draw_longitude_circle( c, longitude ):
        pass


    # set up our triangle
    c = get_letter_canvas( filename )

    # hex grid
    c.setStrokeColor( (0.75, 0.75, 1) )
    # c.setLineWidth( 0.001 )
    # draw_hexes( c, 2 )
    c.setLineWidth( 0.0005 )
    draw_hexes( c, 10 )

    c.setStrokeColor( (0.75,0.75,0.75) )
    d20 = Icosahedron( numeric = True )
    d20.rotate_vertices( rot_x( -s.atan2( s.GoldenRatio-1, s.GoldenRatio ).evalf() ) )
    d20.make_faces()
    mappings = face_mappings( d20 )

    face_plane = d20.faces[16].plane
    rot_mat = mappings.face_dict['q'][0]
    
    bag_o_points = dict()
 
    for lat in range( 90, 171, 5 ):
        for lon in range( 210, 331, 5 ):
            point = line_plane_intersect( two_point_line( \
                _sphere_to_cart( to_rad( lat ).evalf(), to_rad( lon ).evalf() ), zero_3d), face_plane, ray=True )
            mp = point.multiply( rot_mat )
            # c.circle( mp[0],mp[1],0.002,fill=1,stroke=0)
            bag_o_points[(lat,lon)] = mp
                
    for lat in range( 90, 169, 5 ):
        for lon in range( 210, 330, 5 ):
            p0 = bag_o_points[(lat, lon)]
            p1 = bag_o_points[(lat+5,lon)]
            p2 = bag_o_points[(lat,lon+5)]
            
            if lon % 5:
                c.setLineWidth( 0.0005 )
            else:
                c.setLineWidth( 0.001 )
            
            c.line( p0[0],p0[1],p1[0],p1[1] )
            
            if lat % 5:
                c.setLineWidth( 0.0005 )
            else:
                c.setLineWidth( 0.001 )
                
            c.line( p0[0],p0[1],p2[0],p2[1] )


    c.showPage()
    c.save()
Ejemplo n.º 3
0
def make_map( filename ):

    # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
    # helpers
    # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 

    def _map_point( point ):
        line = two_point_line( point, zero_3d )
        for hit in d20.face_hit( line ):
            # print hit[0]
            mapped_point = mappings.map_point( hit[0], hit[1] )
            if mapped_point:
                new_x, new_y = mapped_point
                c.circle( sx(new_x), sy(new_y), 0.5, stroke=0, fill=1  )

    def _sphere_to_cart( theta, phi ):
        return vector_3d( \
            s.sin( theta ) * s.cos( phi ), \
            s.cos( theta ), \
            s.sin( theta ) * s.sin( phi ) )
            
    def _arc_azimuth( start_az, end_az, inclin, step ):
        for azimuth in range( start_az, end_az, step ):
            _map_point( _sphere_to_cart( to_rad( inclin ).evalf(), to_rad(azimuth).evalf() ))
    
    def _arc_inclin(  start_inc, end_inc, azimuth, step ):
        for inclin in range( start_inc, end_inc, step ):
            _map_point( _sphere_to_cart( to_rad( inclin ).evalf(), to_rad(azimuth).evalf() ))
            
    def _plot_skeleton():
        th = (s.sqrt(3)/2).evalf()

        c.line( sx(0), sy(2 * th) , sx(0.5), sy(3 * th) )
        c.line( sx(0.5), sy(th) , sx(1.5), sy(3 * th) )
        c.line( sx(1), sy(0) , sx(2.5), sy(3 * th) )
        c.line( sx(2), sy(0) , sx(3.5), sy(3 * th) )
        c.line( sx(3), sy(0) , sx(4.5), sy(3 * th) )
        c.line( sx(4), sy(0) , sx(5), sy(2 * th) )
        c.line( sx(5), sy(0) , sx(5.5), sy(th) )

        c.line( sx(0), sy( 2 * th ), sx(1), sy(0) )        
        c.line( sx(0.5), sy( 3 * th ), sx(2), sy(0) )        
        c.line( sx(1.5), sy( 3 * th ), sx(3), sy(0) )        
        c.line( sx(2.5), sy( 3 * th ), sx(4), sy(0) )        
        c.line( sx(3.5), sy( 3 * th ), sx(5), sy(0) )        
        c.line( sx(4.5), sy( 3 * th ), sx(5.5), sy( th ) )   
        
        c.line( sx(0), sy( 2 * th), sx( 5 ), sy( 2*th ) )     
        c.line( sx(0.5), sy(th), sx( 5.5 ), sy( th ) )     
            
    # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
    # main
    # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
            
    c = canvas.Canvas( filename, pagesize=( 17*72, 11*72 ) )
    d20 = Icosahedron( numeric = True )
    d20.rotate_vertices( rot_x( -s.atan2( s.GoldenRatio-1, s.GoldenRatio ).evalf() ) )
    d20.make_faces()
    mappings = face_mappings( d20 )
    
    inc_factor = (s.pi/180).evalf()
    az_factor = (s.pi/180).evalf()
    
    c.setFillColorRGB( .5,.5, 1 )
    
    for azimuth in range( 0, 360, 5 ):
         _arc_inclin( 20, 161, azimuth, 1 )
    
    for inclin in range( 20, 161, 5 ):
         _arc_azimuth( 0, 360, inclin, 1 )
    
    c.setStrokeColorRGB( .5,.5, .5 )    
    _plot_skeleton()

    c.showPage()
    c.save()