Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

model::d3::point_xyz

3D point in Cartesian coordinate system

Model of

Point Concept

Synopsis

template<typename CoordinateType, typename CoordinateSystem>
class model::d3::point_xyz
      : public model::point< CoordinateType, 3, cs::cartesian >
{
  // ...
};

Template parameter(s)

Parameter

Default

Description

typename CoordinateType

numeric type, for example, double, float, int

typename CoordinateSystem

cs::cartesian

coordinate system, defaults to cs::cartesian

Constructor(s)

Function

Description

Parameters

point_xyz()

Default constructor, no initialization.

point_xyz(CoordinateType const & x, CoordinateType const & y, CoordinateType const & z)

Constructor with x/y/z values.

CoordinateType const &: x:

CoordinateType const &: y:

CoordinateType const &: z:

Member Function(s)

Function

Description

Parameters

Returns

constexpr CoordinateType const & x()

Get x-value.

constexpr CoordinateType const & y()

Get y-value.

constexpr CoordinateType const & z()

Get z-value.

void x(CoordinateType const & v)

Set x-value.

CoordinateType const &: v:

void y(CoordinateType const & v)

Set y-value.

CoordinateType const &: v:

void z(CoordinateType const & v)

Set z-value.

CoordinateType const &: v:

Header

Either

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

Or

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

Examples

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

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

namespace bg = boost::geometry;

int main()
{
    bg::model::d3::point_xyz<double> point1;
    bg::model::d3::point_xyz<double> point2(3, 4, 5); 1

    bg::set<0>(point1, 1.0); 2
    point1.y(2.0); 3
    point1.z(4.0);

    double x = bg::get<0>(point1); 4
    double y = point1.y(); 5
    double z = point1.z();

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

1

Construct, assigning coordinates.

2

Set a coordinate, generic.

3

Set a coordinate, class-specific (Note: prefer bg::set()).

4

Get a coordinate, generic.

5

Get a coordinate, class-specific (Note: prefer bg::get()).

Output:

1, 2, 4
Notes
[Note] 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


PrevUpHomeNext