Changeset 2414 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Mar 24, 2019, 8:35:53 PM (6 years ago)
Author:
lfita
Message:

Woring on 'ang_circ'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2413 r2414  
    205205    return rotlines
    206206
     207def dist_points(ptA, ptB):
     208    """ Function to provide the distance between two points
     209      ptA: coordinates of the point A [yA, xA]
     210      ptB: coordinates of the point B [yB, xB]
     211    >>> dist_points([1.,1.], [-1.,-1.])
     212    2.82842712475
     213    """
     214    fname = 'dist_points'
     215
     216    dist = np.sqrt( (ptA[0]-ptB[0])**2 + (ptA[1]-ptB[1])**2)
     217
     218    return dist
     219
    207220####### ###### ##### #### ### ## #
    208221# Shapes/objects
     
    283296    return hyperbola_p, hyperbola_n
    284297
    285 def dist_points(ptA, ptB):
    286     """ Function to provide the distance between two points
    287       ptA: coordinates of the point A [yA, xA]
    288       ptB: coordinates of the point B [yB, xB]
    289     >>> dist_points([1.,1.], [-1.,-1.])
    290     2.82842712475
    291     """
    292     fname = 'dist_points'
    293 
    294     dist = np.sqrt( (ptA[0]-ptB[0])**2 + (ptA[1]-ptB[1])**2)
    295 
    296     return dist
    297 
    298298def circ_sec(ptA, ptB, radii, Nang=100):
    299299    """ Function union of point A and B by a section of a circle
     
    314314        quit(-1)
    315315
    316     if ptA[0] > ptB[0]:
    317         tottheta = np.atan2(ptA[0]-ptB[0],ptA[1]-ptB[1])
    318         yc=ptA[0]
    319         if ptA[1] < ptB[0]:
    320             sign = -1
    321             xc=ptA[1]+radii
    322         else:
    323             sign = 1
    324             xc=ptA[1]-radii
    325     else:
    326         tottheta = np.atan2(ptB[0]-ptA[0],ptB[1]-ptA[1])
    327         yc=ptA[0]
    328         if ptA[1] < ptB[0]:
    329             sign = 1
    330             xc=ptA[1]+radii
    331         else:
    332             sign = -1
    333             xc=ptA[1]-radii
     316    # Coordinate increments
     317    dAB = np.abs(ptA-ptB)
     318
     319    # angle of the circular section joining points
     320    tottheta = 2.*np.arcsin(distAB/2./radii)
     321
     322    # center along coincident bisection of the union
     323    xcc = -radii
     324    ycc = 0.
     325
     326    # Angle of the points
     327    pttheta = np.arctan2(ptB[0]-ptA[0],ptB[1]-ptA[1])
     328
     329    # rotating the position of the center
     330    rotang = np.pi/2.-pttheta
     331
     332    newcc = rotate_line2D(np.array([[ycc,xcc], [0.,0.]]), rotang)
     333    print newcc
     334
     335    quit()
    334336
    335337    dtheta = np.abs(tottheta)/(Nang-1)
    336338    if sign == 1:
    337339        dtheta = dtheta*(-1.)
     340
     341    print 'Lluis tottheta:', tottheta*180./np.pi, 'dtheta:', dtheta*180./np.pi, 'c:', xc,yc
    338342
    339343    circ_sec = np.zeros((Nang,2), dtype=np.float)
     
    343347        y = radii*np.sin(theta)
    344348
    345         circ_sec[ia,:] = [x+xc,y+yc]
     349        circ_sec[ia,:] = [y+yc,x+xc]
     350        print ia, 'Lluis xy:', x,y, 'circ', circ_sec[ia,:]
    346351   
    347352    return circ_sec
Note: See TracChangeset for help on using the changeset viewer.