- Timestamp:
- Jun 22, 2019, 8:45:35 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/geometry_tools.py
r2617 r2622 33 33 # max_coords_poly: Function to provide the extremes of the coordinates of a polygon 34 34 # mirror_polygon: Function to reflex a polygon for a given axis 35 # mod_vec: Function to compute the module of a vector 35 36 # position_sphere: Function to tranform fom a point in lon, lat deg coordinates to 36 37 # cartesian coordinates over an sphere … … 267 268 268 269 return dist 270 271 def mod_vec(vec): 272 """ Function to compute the module of a vector 273 vec: vector [y, x] 274 >>> mod_vec([1., 1.]) 275 1.41421356237 276 """ 277 fname = 'mod_vec' 278 279 mod = np.sqrt(vec[0]*vec[0] + vec[1]*vec[1]) 280 281 return mod 282 283 print mod_vec([1., 1.]) 284 quit() 285 286 def angle_vectors2D(veca, vecb): 287 """ Angle between two vectors 288 veca: angle A [ya, xa] 289 vecb: angle B [yb, xb] 290 NOTE: angle from A to B 291 >>> angle_vectors2D([1.,0.], [0.,1.]) 292 293 """ 294 fname = 'angle_vectors2D' 295 296 moda = mod_vec(veca) 297 modb = mod_vec(vecb) 298 299 return alpha 269 300 270 301 def max_coords_poly(polygon): … … 1523 1554 >>> plgs = {'sqra': polya, 'sqrb': polyb} 1524 1555 >>> pile_polygons(pns, plgs) 1525 1556 [[-0.75 -0.5 ] 1557 [ 0.75 -0.5 ] 1558 [ 0.75 0.5 ] 1559 [-0.75 0.5 ]] 1526 1560 """ 1527 1561 fname = 'pile_polygons' … … 1537 1571 poly = polygons[polyn] 1538 1572 Npts = poly.shape[0] 1539 print ' LLuis shapes ipoly', ipoly.shape, 'poly', poly.shape1540 1573 Nint, inti, intp, pts = fsci.module_scientific.crossingpoints_polys( \ 1541 1574 nvertexa=iNpts, nvertexb=Npts, nvertexab=iNpts*Npts, polya=ipoly, \ 1542 1575 polyb=poly) 1543 print Nint 1544 for ip in range(Nint): 1545 print ip, ':', inti[ip], intp[ip], '=', pts[ip] 1576 iip=0 1577 for ip in Nint: 1578 newipoly = ipoly[iip:inti] 1579 1546 1580 1547 1581 return pilepolygons 1548 1549 #pns = ['sqra', 'sqrb']1550 #polya = np.array([[-0.5, -0.75], [0.5, -0.75], [0.5, 0.75], [-0.5, 0.75]])1551 #polyb = np.array([[-0.75, -0.5], [0.75, -0.5], [0.75, 0.5], [-0.75, 0.5]])1552 #plgs = {'sqra': polya, 'sqrb': polyb}1553 #pile_polygons(pns, plgs)1554 1555 1556 1582 1557 1583 ####### ###### ##### #### ### ## #
Note: See TracChangeset
for help on using the changeset viewer.