| Home | Libraries | People | FAQ | More

#### model::point

Basic point class, having coordinates defined in a neutral way.

###### Description

Defines a neutral point class, fulfilling the Point Concept. Library users can use this point class, or use their own point classes. This point class is used in most of the samples and tests of Boost.Geometry. This point class is used occasionally within the library, where a temporary point class is necessary.

###### Model of

Point Concept

###### Synopsis

    template<typename CoordinateType, std::size_t DimensionCount, typename CoordinateSystem>
    class model::point
    {
      // ...
    };

###### Template parameter(s)

Parameter | Description
--- | ---
typename CoordinateType | numerical type (int, double, ttmath, ...)
std::size_t DimensionCount | number of coordinates, usually 2 or 3
typename CoordinateSystem | coordinate system, for example cs::cartesian

###### Constructor(s)

Function | Description | Parameters
--- | --- | ---
    point()
| Default constructor, no initialization. |
    template<typename C, std::enable_if_t< geometry::detail::is_coordinates_number_leq< C, 1, DimensionCount >::value, int >>
    point(CoordinateType const & v0)
| Constructor to set one value. | CoordinateType const &: v0:
    template<typename C, std::enable_if_t< geometry::detail::is_coordinates_number_leq< C, 2, DimensionCount >::value, int >>
    point(CoordinateType const & v0, CoordinateType const & v1)
| Constructor to set two values. | CoordinateType const &: v0: CoordinateType const &: v1:
    template<typename C, std::enable_if_t< geometry::detail::is_coordinates_number_leq< C, 3, DimensionCount >::value, int >>
    point(CoordinateType const & v0, CoordinateType const & v1, CoordinateType const & v2)
| Constructor to set three values. | CoordinateType const &: v0: CoordinateType const &: v1: CoordinateType const &: v2:

###### Member Function(s)

Function | Description | Parameters | Returns
--- | --- | --- | ---
    template<std::size_t K>
    CoordinateType const & get()
| Get a coordinate. |  | the coordinate
    template<std::size_t K>
    void set(CoordinateType const & value)
| Set a coordinate. | CoordinateType const &: value: value to set |

###### Header

Either

`#include <boost/geometry/geometries/geometries.hpp>`

Or

`#include <boost/geometry/geometries/point.hpp>`

###### Examples

Declaration and use of the Boost.Geometry model::point, modelling the Point Concept

    #include <iostream>
    #include <boost/geometry.hpp>

    namespace bg = boost::geometry;

    int main()
    {
        bg::model::point<double, 2, bg::cs::cartesian> point1;
        bg::model::point<double, 3, bg::cs::cartesian> point2(1.0, 2.0, 3.0);

        bg::set<0>(point1, 1.0);
        point1.set<1>(2.0);

        double x = bg::get<0>(point1);
        double y = point1.get<1>();

        std::cout << x << ", " << y << std::endl;
        return 0;
    }

| Construct, assigning three coordinates
| Set a coordinate, generic.
| Set a coordinate, class-specific (Note: prefer `bg::set()`).
| Get a coordinate, generic.
| Get a coordinate, class-specific (Note: prefer `bg::get()`).

Output:

    1, 2

###### Notes

| Note
Coordinates are not initialized. If the constructor with parameters is not called and points are not assigned using `set` or `assign` then the coordinate values will contain garbage