libpysal.cg.get_ray_segment_intersect

libpysal.cg.get_ray_segment_intersect(ray, seg)[source]

Returns the intersection of a ray and line segment.

Parameters:
raylibpysal.cg.Ray

A ray to check for an intersection.

seglibpysal.cg.LineSegment

A segment to check for an intersection against ray.

Returns:
intersection{libpysal.cg.Point, libpysal.cg.LineSegment, None}

The intersecting point or line between ray and seg if an intersection exists or None if ray and seg do not intersect.

Examples

>>> ray = Ray(Point((0, 0)), Point((0, 1)))
>>> seg = LineSegment(Point((-1, 10)), Point((1, 10)))
>>> i = get_ray_segment_intersect(ray, seg)
>>> isinstance(i, Point)
True
>>> str(i)
'(0.0, 10.0)'
>>> seg2 = LineSegment(Point((10, 10)), Point((10, 11)))
>>> get_ray_segment_intersect(ray, seg2)