Changeset 2241

Show
Ignore:
Timestamp:
03/02/08 23:55:45 (6 months ago)
Author:
arj..@yirdis.nl
Message:

updated docstrings of geometry module

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphas/trunk/gaphas/geometry.py

    r1794 r2241  
    55intersections) 
    66 
    7 A point is represented as a tuple (x, y)
     7A point is represented as a tuple `(x, y)`
    88 
    99""" 
     
    129129        """ 
    130130        Create a new Rectangle is the union of the current rectangle 
    131         with another Rectangle, tuple (x,y) or tuple (x, y, width, height)
     131        with another Rectangle, tuple `(x,y)` or tuple `(x, y, width, height)`
    132132 
    133133        >>> r=Rectangle(5, 7, 20, 25) 
     
    212212    def __contains__(self, obj): 
    213213        """ 
    214         Check if a point (x, y) in inside rectangle (x, y, width, height) 
     214        Check if a point `(x, y)` in inside rectangle `(x, y, width, height)` 
    215215        or if a rectangle instance is inside with the rectangle. 
    216216 
     
    253253def distance_point_point(point1, point2=(0., 0.)): 
    254254    """ 
     255    Return the distance from point ``point1`` to ``point2``. 
     256 
    255257    >>> '%.3f' % distance_point_point((0,0), (1,1)) 
    256258    '1.414' 
     
    263265def distance_point_point_fast(point1, point2): 
    264266    """ 
     267    Return the distance from point ``point1`` to ``point2``. This version is 
     268    faster than ``distance_point_point()``, but less precise. 
     269 
    265270    >>> distance_point_point_fast((0,0), (1,1)) 
    266271    2 
     
    273278def distance_rectangle_point(rect, point): 
    274279    """ 
    275     Return the distance (fast) from a rectangle (x, y, width, height) to a line. 
     280    Return the distance (fast) from a rectangle ``(x, y, width, height)`` to a 
     281    ``point``. 
    276282 
    277283    >>> distance_rectangle_point(Rectangle(0, 0, 10, 10), (11, -1)) 
     
    301307def point_on_rectangle(rect, point, border=False): 
    302308    """ 
    303     Return the point on which @point can be projecten on the rectangle. 
    304     border = True will make sure the point is bound to the border of 
     309    Return the point on which ``point`` can be projecten on the rectangle. 
     310    ``border = True`` will make sure the point is bound to the border of 
    305311    the reactangle. Otherwise, if the point is in the rectangle, it's okay. 
    306312     
     
    365371def distance_line_point(line_start, line_end, point): 
    366372    """ 
    367     Calculate the distance of a point from a line. The line is marked 
    368     by begin and end point line_start and line_end.  
     373    Calculate the distance of a ``point`` from a line. The line is marked 
     374    by begin and end point ``line_start`` and ``line_end``.  
    369375 
    370376    A tuple is returned containing the distance and point on the line. 
     
    413419def intersect_line_line(line1_start, line1_end, line2_start, line2_end): 
    414420    """ 
     421    Find the point where the lines (segments) defined by 
     422    ``(line1_start, line1_end)`` and ``(line2_start, line2_end)`` intersect. 
     423    If no intersecion occurs, ``None`` is returned. 
     424 
    415425    >>> intersect_line_line((0, 0), (10, 10), (3, 0), (8, 10)) 
    416426    (6.0, 6.0) 
     
    452462def rectangle_contains(inner, outer): 
    453463    """ 
    454     Returns True if inner rect is contained in outer rect. 
     464    Returns True if ``inner`` rect is contained in ``outer`` rect. 
    455465    """ 
    456466    ix, iy, iw, ih = inner 
     
    461471def rectangle_intersects(recta, rectb): 
    462472    """ 
    463     Return True if recta and rectb intersect. 
     473    Return True if ``recta`` and ``rectb`` intersect. 
    464474 
    465475    >>> rectangle_intersects((5,5,20, 20), (10, 10, 1, 1))