Logo Search packages:      
Sourcecode: inkscape version File versions

boost::optional<LineSegment> Geom::rect_line_intersect ( Geom::Rect r,
Geom::LineSegment  ls 

Determine whether & where an (infinite) line intersects a rectangle.

c0, c1 are diagonal corners of the rectangle and p1, p1 are distinct points on the line

A list (possibly empty) of points of intersection. If two such points (say r0 and r1) then it is guaranteed that the order of r0, r1 along the line is the same as the that of c0, c1 (i.e., the vectors r1 - r0 and p1 - p0 point into the same direction).

Definition at line 326 of file geom.cpp.

References Geom::D2< Interval >::max(), Geom::D2< Interval >::min(), and rect_line_intersect().

    std::vector<Point> results;
    results =  rect_line_intersect(r.min(), r.max(), ls[0], ls[1]);
    if(results.size() == 2) {
        return LineSegment(results[0], results[1]);
    return boost::optional<LineSegment>();

Generated by  Doxygen 1.6.0   Back to index