本文整理汇总了C++中Star::getCoords方法的典型用法代码示例。如果您正苦于以下问题:C++ Star::getCoords方法的具体用法?C++ Star::getCoords怎么用?C++ Star::getCoords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Star
的用法示例。
在下文中一共展示了Star::getCoords方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: neighbors
StarSet StarMap::neighbors(const Star& star, double threshold) const
{
auto c = star.getCoords();
std::vector<std::vector<int>> idx;
std::vector<std::vector<double>> dists;
double t2 = threshold * threshold;
spatial_index_->radiusSearch(
toMatrix(&c),
idx,
dists,
t2,
flann::SearchParams()
);
auto pred = [star](const Star& v)
{
return v != star;
};
auto xform = [this](int i)
{
return byIndex().at(i);
};
/* lol, iterators */
auto xbegin = make_transform_iterator(idx.front().begin(), xform);
auto xend = make_transform_iterator(idx.front().end(), xform);
auto begin = make_filter_iterator(pred, xbegin, xend);
auto end = make_filter_iterator(pred, xend, xend);
return StarSet(begin, end);
}
示例2: nearestNeighbor
Star StarMap::nearestNeighbor(const Star& star, double threshold) const
{
auto c = star.getCoords();
int index[2] = { 0 };
double dist[2] = { 0 };
flann::Matrix<int> i = toMatrix(index, 1, 2);
flann::Matrix<double> d = toMatrix(dist, 1, 2);
spatial_index_->knnSearch(toMatrix(&c), i, d, 2, flann::SearchParams());
return (dist[1] < threshold*threshold) ? byIndex().at(index[1]) : Star();
}
示例3:
ss << fixed << "(" << c.x() << ", " << c.y() << ", " << c.z() << ")";
return os << ss.str();
}
CommandTable cmds
{
{
"nearest",
[](ArgList args)
{
Star from = g.getStar(getArg(args, 1));
Star to =
g.nearestNeighbor(from, getArg<double>(args, 2));
cout << "Neighbor: " << to.getName()
<< " Distance: "
<< from.getCoords().distance(to.getCoords())
<< endl;
}
},
{
"neighbors",
[](ArgList args)
{
Star from = g.getStar(getArg(args, 1));
double t = getArg<double>(args, 2);
for (auto n : g.neighbors(from, t))
{
cout << "Neighbor: " << n.getName()
<< " Distance: "
<< from.getCoords().distance(n.getCoords())
<< endl;