rickthepizza / pyeuclid

Automatically exported from code.google.com/p/pyeuclid
0 stars 0 forks source link

2D Tengential Intersections Cause AssertionErrors #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Intersecting a circle with Line2 (2D line) along a tangent causes an
AssertionError when constructing the resultant Line2.  The documentation
states that tangential cases will result in a zero length line (start and
end points the same), but the Line2 class checks for this and throws an
assertion.

Example:
>>> from euclid import *
>>> c = Circle(Point2(0.0, 0.0), 1.0)
>>> l = Line2(Point2(0.0, 1.0), Point2(1.0, 1.0))
>>> l.intersect(c)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "euclid.py", line 1602, in intersect
    return other._intersect_line2(self)
  File "euclid.py", line 1679, in _intersect_line2
    return _intersect_line2_circle(other, self)
  File "euclid.py", line 1463, in _intersect_line2_circle
    L.p.y + u2 * L.v.y))
  File "euclid.py", line 1579, in __init__
    raise AttributeError, 'Line has zero-length vector'
AttributeError: Line has zero-length vector

I'm not sure if I should expect a zero length line segment
(LineSegment2(<0.00, 1.00> to <0.00, 1.00>)) which could cause problems if
you assume that all line segments have length or a Point2 which could cause
problems if (Point2(0.00, 0.00)) you assume that all intersections return
LineSegment2 classes.

Versions tested:
python 2.5.1 and 2.6
euclid.py (unversioned from google-code page.  MD5:
0e98208edc78221be8ec23ac85960ee7)
Ubuntu 7.0.4 (older version)

Original issue reported on code.google.com by rts....@gmail.com on 19 Jan 2009 at 10:54

GoogleCodeExporter commented 9 years ago
Thanks, fixed in r27; this kind of intersection now returns a Point2 (untested).

Original comment by Alex.Hol...@gmail.com on 20 Jan 2009 at 11:43