Changeset 2651 in lmdz_wrf for trunk


Ignore:
Timestamp:
Jun 30, 2019, 3:39:52 PM (5 years ago)
Author:
lfita
Message:

Adding:

  • `rotate_objdic_2D': Function to rotate 2D plain the vertices of all polygons of an object
Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2649 r2651  
    4040# rm_consecpt_polygon: Function to remove consecutive same point of a polygon
    4141# rotate_2D: Function to rotate a vector by a certain angle in the plain
     42# rotate_objdic_2D: Function to rotate 2D plain the vertices of all polygons of an object
    4243# rotate_polygon_2D: Function to rotate 2D plain the vertices of a polygon
    4344# rotate_line2D: Function to rotate a line given by 2 pairs of x,y coordinates by a
     
    183184
    184185    return rotvecs
     186
     187def rotate_objdic_2D(objdic, angle):
     188    """ Function to rotate 2D plain the vertices of all polygons of an object
     189      objdic= dictionary with all the polygons of the object
     190      angle= angle to rotate [rad]
     191    """
     192    fname = 'rotate_objdic_2D'
     193
     194    rotobjdic = dict(objdic)
     195
     196    for secn in objdic.keys():
     197        objv = objdic[secn]
     198        vectors = objv[0]
     199        rotvecs = np.zeros(vectors.shape, dtype=np.float)
     200
     201        Nvecs = vectors.shape[0]
     202        for iv in range(Nvecs):
     203            rotvecs[iv,:] = rotate_2D(vectors[iv,:], angle)
     204        rotobjdic[secn] = rotvecs
     205
     206    return rotobjdic
    185207
    186208def rotate_line2D(line, angle):
     
    25192541        lw = secv[3]
    25202542
    2521         plt.plot(poly[:,1], poly[:,0], lt, color=lc, linewdith=lw)
     2543        plt.plot(poly[:,1], poly[:,0], lt, color=lc, linewidth=lw)
    25222544
    25232545    return
  • trunk/tools/nautical.py

    r2650 r2651  
    347347            hsail = geo.circ_sec(bow, endsail, lsail*2.15)
    348348    else:
    349         hsail0 = p_sinusiode(length=lsail, amp=0.2, lamb=0.75, N=dpts)
     349        hsail0, sailsec, saildic = geo.p_sinusiode(length=lsail, amp=0.2, lamb=0.75, N=dpts)
    350350        hsail = np.zeros((dpts,2), dtype=np.float)
    351351        hsail[:,0] = hsail0[:,1]
     
    365365            msail = geo.circ_sec(endsail, begsail, lsail*2.15)
    366366    else:
    367         msail0 = p_sinusiode(length=lsail, amp=0.25, lamb=1., N=dpts)
     367        msail0, sailsec, saildic = geo.p_sinusiode(length=lsail, amp=0.25, lamb=1., N=dpts)
    368368        msail = np.zeros((dpts,2), dtype=np.float)
    369369        msail[:,0] = msail0[:,1]
Note: See TracChangeset for help on using the changeset viewer.