本文整理汇总了C++中Point::DistanceTo方法的典型用法代码示例。如果您正苦于以下问题:C++ Point::DistanceTo方法的具体用法?C++ Point::DistanceTo怎么用?C++ Point::DistanceTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point::DistanceTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(){
SwapCase a;
SwapCase b;
a.num = 2;
b.num = 6;
swap<int>(a.num, b.num);
a.fnum = -90;
b.fnum = 200;
swap<float>(a.fnum, b.fnum);
a.lett = 'P';
b.lett = 'Q';
swap<char>(a.lett, b.lett);
a.yep = false;
b.yep = true;
swap<bool>(a.yep, b.yep);
//-----------------------------------------------
Point<int> c;
Point<int> d;
c.SetZero();
d.SetZero();
c.SetPoint(56, 29);
d.SetPoint(852, 213);
c.DistanceTo(d);
//-------------------
Point<float> e;
Point<float> f;
e.SetZero();
f.SetZero();
e.SetPoint(56, 29);
f.SetPoint(852, 213);
e.DistanceTo(f);
return 0;
}
示例2: configure
/**
This is based on a nearest node criterion to all boundaries.
@todo Improve efficiency. In most cases, we should be able to specify boundaries as planes
@todo Somewhat dependent on the resolution of the model boundary
*/
bool OmegaBDistanceConfigurator::configure(Model& m) const
{
Point<3> ebc;
m.UpdateIndices();
vector<size_t> omega_ids;
omega_ids.reserve(m.Region("Model").Elements());
for (const auto& eit : m.Region("Model").ElementVector())
{
ebc = eit->BaryCenter();
double dmin = numeric_limits<double>::max();
for (Model::boundaryIterator bit = m.BoundariesBegin(); bit != m.BoundariesEnd(); ++bit)
{
if (!is_main_boundary_id(bit->first.second))
continue;
for (const auto& bnit : bit->second.NodeVector())
{
double const dist = ebc.DistanceTo(bnit->Coordinate());
if (dist < dmin)
dmin = dist;
}
}
if (dmin >= dist_)
omega_ids.push_back(eit->Idx());
}
if (omega_ids.size()) {
m.FormRegionFrom("omega", omega_ids);
return true;
}
return false;
}
示例3: Length
//we don't define setters for this class, so it would technically be more efficient to calculate
//length in our constructor and then store it as a property...
double Length()
{
return p1.DistanceTo(p2);
}