| Home | Libraries | People | FAQ | More

##### disjoint

Checks if two geometries are disjoint.

###### Synopsis

    template<typename Geometry1, typename Geometry2>
    bool disjoint(Geometry1 const & geometry1, Geometry2 const & geometry2)

###### Parameters

Type | Concept | Name | Description
--- | --- | --- | ---
Geometry1 const & | Any type fulfilling a Geometry Concept | geometry1 | A model of the specified concept
Geometry2 const & | Any type fulfilling a Geometry Concept | geometry2 | A model of the specified concept

###### Returns

Returns true if two geometries are disjoint

###### Header

Either

`#include <boost/geometry.hpp>`

Or

`#include <boost/geometry/algorithms/disjoint.hpp>`

###### Conformance

The function disjoint implements function Disjoint from the OGC Simple Feature Specification.

###### Supported geometries

| Point | Segment | Box | Linestring | Ring | Polygon | MultiPoint | MultiLinestring | MultiPolygon | Variant
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
Point |  |  |  |  |  |  |  |  |  |
Segment |  |  |  |  |  |  |  |  |  |
Box |  |  |  |  |  |  |  |  |  |
Linestring |  |  |  |  |  |  |  |  |  |
Ring |  |  |  |  |  |  |  |  |  |
Polygon |  |  |  |  |  |  |  |  |  |
MultiPoint |  |  |  |  |  |  |  |  |  |
MultiLinestring |  |  |  |  |  |  |  |  |  |
MultiPolygon |  |  |  |  |  |  |  |  |  |
Variant |  |  |  |  |  |  |  |  |  |

###### Examples

Checks if two geometries are disjoint

    #include <iostream>

    #include <boost/geometry.hpp>
    #include <boost/geometry/geometries/point_xy.hpp>
    #include <boost/geometry/geometries/polygon.hpp>

    namespace bg = boost::geometry;

    int main()
    {
        // Checks if two geometries are disjoint, which means that two geometries have zero intersection.
        bg::model::polygon<bg::model::d2::point_xy<double> > poly1;
        bg::read_wkt("POLYGON((0 2,-2 0,-4 2,-2 4,0 2))", poly1);
        bg::model::polygon<bg::model::d2::point_xy<double> > poly2;
        bg::read_wkt("POLYGON((2 2,4 4,6 2,4 0,2 2))", poly2);
        bool check_disjoint = bg::disjoint(poly1, poly2);
        if (check_disjoint) {
             std::cout << "Disjoint: Yes" << std::endl;
        } else {
            std::cout << "Disjoint: No" << std::endl;
        }

        bg::model::polygon<bg::model::d2::point_xy<double> > poly3;
        bg::read_wkt("POLYGON((0 2,2 4,4 2,2 0,0 2))", poly3);
        check_disjoint = bg::disjoint(poly1, poly3);
        if (check_disjoint) {
             std::cout << "Disjoint: Yes" << std::endl;
        } else {
            std::cout << "Disjoint: No" << std::endl;
        }

        return 0;
    }

| Convenient namespace alias

Output:

    Disjoint: Yes
    Disjoint: No