Changeset 2241
- Timestamp:
- 03/02/08 23:55:45 (6 months ago)
- Files:
-
- gaphas/trunk/gaphas/geometry.py (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphas/trunk/gaphas/geometry.py
r1794 r2241 5 5 intersections) 6 6 7 A point is represented as a tuple (x, y).7 A point is represented as a tuple `(x, y)`. 8 8 9 9 """ … … 129 129 """ 130 130 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)`. 132 132 133 133 >>> r=Rectangle(5, 7, 20, 25) … … 212 212 def __contains__(self, obj): 213 213 """ 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)` 215 215 or if a rectangle instance is inside with the rectangle. 216 216 … … 253 253 def distance_point_point(point1, point2=(0., 0.)): 254 254 """ 255 Return the distance from point ``point1`` to ``point2``. 256 255 257 >>> '%.3f' % distance_point_point((0,0), (1,1)) 256 258 '1.414' … … 263 265 def distance_point_point_fast(point1, point2): 264 266 """ 267 Return the distance from point ``point1`` to ``point2``. This version is 268 faster than ``distance_point_point()``, but less precise. 269 265 270 >>> distance_point_point_fast((0,0), (1,1)) 266 271 2 … … 273 278 def distance_rectangle_point(rect, point): 274 279 """ 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``. 276 282 277 283 >>> distance_rectangle_point(Rectangle(0, 0, 10, 10), (11, -1)) … … 301 307 def point_on_rectangle(rect, point, border=False): 302 308 """ 303 Return the point on which @pointcan be projecten on the rectangle.304 border = Truewill make sure the point is bound to the border of309 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 305 311 the reactangle. Otherwise, if the point is in the rectangle, it's okay. 306 312 … … 365 371 def distance_line_point(line_start, line_end, point): 366 372 """ 367 Calculate the distance of a pointfrom a line. The line is marked368 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``. 369 375 370 376 A tuple is returned containing the distance and point on the line. … … 413 419 def intersect_line_line(line1_start, line1_end, line2_start, line2_end): 414 420 """ 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 415 425 >>> intersect_line_line((0, 0), (10, 10), (3, 0), (8, 10)) 416 426 (6.0, 6.0) … … 452 462 def rectangle_contains(inner, outer): 453 463 """ 454 Returns True if inner rect is contained in outerrect.464 Returns True if ``inner`` rect is contained in ``outer`` rect. 455 465 """ 456 466 ix, iy, iw, ih = inner … … 461 471 def rectangle_intersects(recta, rectb): 462 472 """ 463 Return True if recta and rectbintersect.473 Return True if ``recta`` and ``rectb`` intersect. 464 474 465 475 >>> rectangle_intersects((5,5,20, 20), (10, 10, 1, 1))
