【发布时间】:2018-06-04 07:52:40
【问题描述】:
我正在使用 Boost 库来操作 N 维域中的点。问题是如果不单独设置每个坐标,我找不到初始化它们的方法。
要获取或设置此库的坐标,应使用:
bg::model::point<double, 2, bg::cs::cartesian> point1; // Declaration
point1.set<0>(1.0); // Coordinate 0 set
point1.set<1>(2.0); // Coordinate 1 set
double x = point1.get<0>(); // Coordinate 0 get
double y = point1.get<1>(); // Coordinate 1 get
但是,我使用 N > 100 的 N 维空间中的点,我无法手动为每个坐标编写一行代码。但是这样的事情:
bg::model::point<double, 2, bg::cs::cartesian> point1;
for(int i(0); i<NDIM; ++i){
point1.set<i>(1.0);
}
不起作用,因为坐标的索引需要是 const 值。你能帮我找到一种自动初始化坐标的方法吗?我尝试了很多东西,没有任何效果!
【问题讨论】:
标签: c++ boost constants boost-geometry