Boost logo

Geometry :

Subject: Re: [geometry] Interesection points
From: Hunk (heiko.hoennige_at_[hidden])
Date: 2013-08-16 05:54:46


hello sorry my example was wront

my code is

typedef boost::geometry::model::d2::point_xy<double> point;
typedef boost::geometry::model::ring< point > ring;
typedef boost::geometry::model::polygon< point> Polygon;
typedef boost::geometry::model::linestring< point > linestring;
typedef boost::geometry::model::segment< point > segment;

    Polygon green, blue;
    segment line_one(boost::geometry::make<point>(-1.0, -1.0),
boost::geometry::make<point>(1.0, 1.0));
    segment line_two(boost::geometry::make<point>(4.0, 0.0),
boost::geometry::make<point>(0.0, 4.0));

    linestring one, two;
    boost::geometry::append(one, boost::geometry::make<point>(0.0, 0.0));
    boost::geometry::append(one, boost::geometry::make<point>(4.0, 4.0));
    boost::geometry::append(two, boost::geometry::make<point>(4.0, 0.0));
    boost::geometry::append(two, boost::geometry::make<point>(0.0, 4.0));

    std::vector<point> points, points2, points3;
    boost::geometry::intersection(line_one, line_two, points);
    std::cout << "segments: " << std::endl;
    for (int i = 0; i < points.size(); ++i)
    {
        std::cout << "x: " << points[i].get<0>() << std::endl;
        std::cout << "y: " << points[i].get<1>() << std::endl;

    }

    boost::geometry::intersection(one, two, points2);
    std::cout << "linestring: " << std::endl;
    for (int i = 0; i < points2.size(); ++i)
    {
        std::cout << "x: " << points2[i].get<0>() << std::endl;
        std::cout << "y: " << points2[i].get<1>() << std::endl;

    }
    Polygon polygon;
    boost::geometry::append(polygon, boost::geometry::make<point>(0, 0));
    boost::geometry::append(polygon, boost::geometry::make<point>(4, 0));
    boost::geometry::append(polygon, boost::geometry::make<point>(0, 4));
    boost::geometry::append(polygon, boost::geometry::make<point>(0, 0));

   boost::geometry::intersection(polygon, line_one, points3);
    std::cout << "Polygon: " << std::endl;
    for (int i = 0; i < points3.size(); ++i)
    {
        std::cout << "x: " << points3[i].get<0>() << std::endl;
        std::cout << "y: " << points3[i].get<1>() << std::endl;

    }

he cant do the intersection between segment and polygon.

It is possible to define lines with and origin point and a direction? not
only a segment?

And i want the intersection point on the border of the polygon not the
segment inside.

Thank you for help

--
View this message in context: http://boost-geometry.203548.n3.nabble.com/Interesection-points-tp4025495p4025514.html
Sent from the Boost Geometry mailing list archive at Nabble.com.

Geometry list run by mateusz at loskot.net