本文整理汇总了C++中Point2::z方法的典型用法代码示例。如果您正苦于以下问题:C++ Point2::z方法的具体用法?C++ Point2::z怎么用?C++ Point2::z使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point2
的用法示例。
在下文中一共展示了Point2::z方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: find_element
int RectangularMesh::find_element(const Point2 &point,
bool throw_exception) const
{
const double px = point.x(); // coordinates of the point of interest
const double pz = point.z();
const double x0 = _min_coord.x(); // limits of the rect mesh
const double x1 = _max_coord.x();
const double z0 = _min_coord.z();
const double z1 = _max_coord.z();
// check that the point is within the mesh
const double tol = FIND_CELL_TOLERANCE;
if (px < x0 - tol || px > x1 + tol ||
pz < z0 - tol || pz > z1 + tol)
{
if (throw_exception)
require(false, "The given point " + d2s(point) + " doesn't belong "
"to the rectangular mesh");
return -1; // to show that the point in not here
}
// since the elements of the rectangular mesh are numerated in the following
// way:
// -----------
// | 0 | 1 |
// -----------
// | 2 | 3 |
// -----------
// we can simplify the search of the element containing the given point:
const double hx = (x1 - x0) / _n_elements_x;
const double hz = (z1 - z0) / _n_elements_z;
const int nx = std::min(static_cast<int>((px-x0)/hx), _n_elements_x-1);
const int nz = std::min(static_cast<int>((pz-z0)/hz), _n_elements_z-1);
if (nx < 0 || nx >= _n_elements_x ||
nz < 0 || nz >= _n_elements_z)
{
if (throw_exception)
require(false, "The rectangular element for the point " + d2s(point) +
" wasn't found");
return -1; // to show that the point in not here
}
return (nz*_n_elements_x + nx);
}