# Diff of /trunk/escript/py_src/util.py

revision 2259 by jfenwick, Tue Feb 10 01:49:44 2009 UTC revision 2288 by gross, Tue Feb 24 06:11:48 2009 UTC
# Line 5849  def diameter(domain): Line 5849  def diameter(domain):
5849      @type domain: L{escript.Domain}      @type domain: L{escript.Domain}
5850      @rtype: C{float}      @rtype: C{float}
5851      """      """
5852        out=0
5853        for v in boundingBox(domain): out+=(v[1]-v[0])**2
5854        return sqrt(out)
5855
5856    def boundingBox(domain):
5857        """
5858        Returns the bounding box of a domain
5859
5860        @param domain: a domain
5861        @type domain: L{escript.Domain}
5862        @return: bounding box of the domain
5863        @rtype: C{list} of pairs of C{float}
5864        """
5865      x=domain.getX()      x=domain.getX()
5866      out=0.      out=[]
5867      for i in xrange(domain.getDim()):      for i in xrange(domain.getDim()):
5868         x_i=x[i]         x_i=x[i]
5869         out=max(out,sup(x_i)-inf(x_i))         out.append((inf(x_i),sup(x_i)))
5870      return out      return out
5871
5872    def longestEdge(domain):
5873        """
5874        Returns the length of the longest edge of the domain
5875
5876        @param domain: a domain
5877        @type domain: L{escript.Domain}
5878        @return: longest edge of the domain parallel to the Cartisean axis
5879        @rtype: C{float}
5880        """
5881        return max([v[1]-v[0] for v in boundingBox(domain) ])
5882
5883  #=============================  #=============================
5884  #  #
5885

Legend:
 Removed from v.2259 changed lines Added in v.2288