| 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. |
    point(CoordinateType const & v0, CoordinateType const & v1 = 0, CoordinateType const & v2 = 0)
| Constructor to set one, two or 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);
        point1.set<0>(1.0);
        point1.set<1>(2.0);

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

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

| Construct, assigning three coordinates
| Set a coordinate. Note: prefer using `bg::set<0>(point1, 1.0);`
| Get a coordinate. Note: prefer using `x = bg::get<0>(point1);`

Output:

    1, 2