Changeset 1190


Ignore:
Timestamp:
Apr 4, 2005, 10:33:44 AM (20 years ago)
Author:
prow
Message:

domain(tri,points,use_incribed_circle = False)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/mesh.py

    r1178 r1190  
    5858
    5959    def __init__(self, coordinates, triangles, boundary = None,
    60                  tagged_elements = None, geo_reference = None):
     60                 tagged_elements = None, geo_reference = None,
     61                 use_incribed_circle = False):
    6162        """
    6263        Build triangles from x,y coordinates (sequence of 2-tuples or
     
    9697            self.centroid_coordinates[i] = centroid
    9798
     99#OLD
     100            if use_incribed_circle == False:
    98101            #Midpoints
    99             m0 = array([(x1 + x2)/2, (y1 + y2)/2])
    100             m1 = array([(x0 + x2)/2, (y0 + y2)/2])
    101             m2 = array([(x1 + x0)/2, (y1 + y0)/2])
    102 
    103             #The radius is the distance from the centroid of
    104             #a triangle to the midpoint of the side of the triangle
    105             #closest to the centroid
    106             d0 = sqrt(sum( (centroid-m0)**2 ))
    107             d1 = sqrt(sum( (centroid-m1)**2 ))
    108             d2 = sqrt(sum( (centroid-m2)**2 ))
    109 
    110             self.radii[i] = min(d0, d1, d2)
     102                m0 = array([(x1 + x2)/2, (y1 + y2)/2])
     103                m1 = array([(x0 + x2)/2, (y0 + y2)/2])
     104                m2 = array([(x1 + x0)/2, (y1 + y0)/2])
     105
     106                #The radius is the distance from the centroid of
     107                #a triangle to the midpoint of the side of the triangle
     108                #closest to the centroid
     109                d0 = sqrt(sum( (centroid-m0)**2 ))
     110                d1 = sqrt(sum( (centroid-m1)**2 ))
     111                d2 = sqrt(sum( (centroid-m2)**2 ))
     112
     113                self.radii[i] = min(d0, d1, d2)
     114
     115#NEW
     116            else:
     117                from math import sqrt
     118                a = sqrt((x0-x1)**2+(y0-y1)**2)
     119                b = sqrt((x1-x2)**2+(y1-y2)**2)
     120                c = sqrt((x2-x0)**2+(y2-y0)**2)
     121
     122                self.radii[i]=self.areas[i]/(2*(a+b+c))
    111123
    112124            #Initialise Neighbours (-1 means that it is a boundary neighbour)
Note: See TracChangeset for help on using the changeset viewer.