| Home | Libraries | People | FAQ | More

##### assign_values (2 coordinate values)

Assign two coordinates to a geometry (usually a 2D point)

###### Synopsis

    template<typename Geometry, typename Type>
    void assign_values(Geometry & geometry, Type const & c1, Type const & c2)

###### Parameters

Type | Concept | Name | Description
--- | --- | --- | ---
Geometry & | Any type fulfilling a Geometry Concept | geometry | A model of the specified concept
Type const & | numerical type (int, double, ttmath, ...) to specify the coordinates | c1 | First coordinate (usually x-coordinate)
Type const & | numerical type (int, double, ttmath, ...) to specify the coordinates | c2 | Second coordinate (usually y-coordinate)

###### Header

Either

`#include <boost/geometry.hpp>`

Or

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

###### Example

Shows the usage of assign to set point coordinates, and, besides that, shows how you can initialize ttmath points with high precision

    #include <iostream>
    #include <iomanip>

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

    #if defined(HAVE_TTMATH)
    #  include <boost/geometry/extensions/contrib/ttmath_stub.hpp>
    #endif

    int main()
    {
        using boost::geometry::assign_values;

        boost::geometry::model::d2::point_xy<double> p1;
        assign_values(p1, 1.2345, 2.3456);

    #if defined(HAVE_TTMATH)
        boost::geometry::model::d2::point_xy<ttmath::Big<1,4> > p2;
        assign_values(p2, "1.2345", "2.3456");
    #endif

        std::cout
            << std::setprecision(20)
            << boost::geometry::dsv(p1) << std::endl
    #if defined(HAVE_TTMATH)
            << boost::geometry::dsv(p2) << std::endl
    #endif
            ;

        return 0;
    }

| It is possible to assign coordinates with other types than the coordinate type. For ttmath, you can e.g. conveniently use strings. The advantage is that it then has higher precision, because if doubles are used for assignments the double-precision is used.

Output:

    (1.2344999999999999, 2.3456000000000001)
    (1.2345, 2.3456)

###### See also

- make