本文整理汇总了C++中point::x方法的典型用法代码示例。如果您正苦于以下问题:C++ point::x方法的具体用法?C++ point::x怎么用?C++ point::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类point
的用法示例。
在下文中一共展示了point::x方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
std::tuple<float, point> line::distance(const point &p) const {
float A = p.x() - origin().x();
float B = p.y() - origin().y();
float C = target().x() - origin().x();
float D = target().y() - origin().y();
float dot = A * C + B * D;
float len_sq = C * C + D * D;
float param = dot / len_sq;
float xx, yy;
if (param < 0 || (origin().x() == target().x() && origin().y() == origin().x())) {
xx = origin().x();
yy = origin().y();
}
else if (param > 1) {
xx = target().x();
yy = target().y();
}
else {
xx = origin().x() + param * C;
yy = origin().y() + param * D;
}
float dx = p.x() - xx;
float dy = p.y() - yy;
return std::make_tuple(sqrt(dx * dx + dy * dy), point(xx, yy));
}
示例2: contains
bool map::contains(point<2> p) const
{
return p.x() >= min_x
&& p.x() <= max_x
&& p.y() >= min_y
&& p.y() <= max_y;
}
示例3: boundingRect
/**
* @brief scChunkManager::boundingRect
* @param Center
* @param width
* @return imaginary rectangle containing the set of chunks that matter
*
* Creates a rectangle whose attributes describe which chunks need to be
* paid attention to (i.e. top left is the top left most chunk, bottom right
* is the bottom right most chunk)
*/
QRect scChunkManager::boundingRect(point Center, measure_type width) const {
coord_type xTileMin = std::floor((Center.x() - width) / chunkWidth);
coord_type xTileMax = std::ceil((Center.x() + width) / chunkWidth);
coord_type yTileMin = std::floor((Center.y() - width) / chunkWidth);
coord_type yTileMax = std::ceil((Center.y() + width) / chunkWidth);
return QRect(QPoint(xTileMin, yTileMax), QPoint(xTileMax, yTileMin));
}
示例4: rect
/// \brief Constructs a rect on position (top_left.x, top_left.y), with
/// size bottom_right.x - top_left.x + 1 as width and
/// bottom_right.y - top_left.x + 1 as height
constexpr rect(
point< position_type > const& top_left,
point< position_type > const& bottom_right
):
top_left_(top_left),
size_(
bottom_right.x() - top_left.x() + 1,
bottom_right.y() - top_left.y() + 1
){}
示例5: operator
bool operator()(const point &p1, const point &p2) {
if (p1.x() < p2.x())
return true;
if (p1.x() != p2.x())
return false;
if (p1.y() < p2.y())
return true;
return false;
}
示例6: lowerleft
bool lowerleft(const point<2>& p1, const point<2>& p2)
{
if (p1.y() < p2.y()) return true;
if (p1.y() > p2.y()) return false;
if (p1.x() < p2.x()) return true;
if (p1.x() > p2.x()) return false;
return false; // p1 == p2
}
示例7: contains
constexpr bool contains(
rect< PositionType, SizeType > const& rect,
point< DataType > const& point
){
return
point.x() >= rect.left() &&
point.y() >= rect.top() &&
point.x() < rect.right() &&
point.y() < rect.bottom();
}
示例8: movecount
llint movecount(point a,point b,point c,int n,int m)
{
if(cross(a-b,c-b)==0)return 0;
int x1=min(a.x(),min(b.x(),c.x()));
int x2=max(a.x(),max(b.x(),c.x()));
int y1=min(a.y(),min(b.y(),c.y()));
int y2=max(a.y(),max(b.y(),c.y()));
//cerr<<"###"<<a<<" "<<b<<" "<<c<<endl;
if(x2-x1>=n||y2-y1>=m)return 0;
return (n-x2+x1)*(m-y2+y1);
}
示例9: mag
bool Foam::octreeDataBoundBox::findTightest
(
const label index,
const point& sample,
treeBoundBox& tightest
) const
{
// Get furthest away vertex
point myNear, myFar;
allBb_[index].calcExtremities(sample, myNear, myFar);
const point dist = myFar - sample;
scalar myFarDist = mag(dist);
point tightestNear, tightestFar;
tightest.calcExtremities(sample, tightestNear, tightestFar);
scalar tightestFarDist = mag(tightestFar - sample);
if (tightestFarDist < myFarDist)
{
// Keep current tightest.
return false;
}
else
{
// Construct bb around sample and myFar
const point dist2(fabs(dist.x()), fabs(dist.y()), fabs(dist.z()));
tightest.min() = sample - dist2;
tightest.max() = sample + dist2;
return true;
}
}
示例10: if
scalar arakawaKonorStripesTracerField::tracerAt
(
const point& p,
const Time& t
) const
{
scalar x = p.x() - xOffset;
if (mag(x) <= wavelength / 2)
{
if (p.z() >= z1Start - 1 && p.z() <= z1End - 1)
{
return -rho0*Foam::sin(2*M_PI*x/wavelength);
}
else if (p.z() >= z2Start - 1 && p.z() <= z2End - 1)
{
return rho0*Foam::sin(2*M_PI*x/wavelength);
}
else
{
return 0;
}
}
else
{
return 0;
}
}
示例11: tileIndexToBounds
QRect scChunkManager::tileIndexToBounds(point loc, measure_type chunkWidth) {
coord_type left = loc.x() * chunkWidth;
coord_type up = (loc.y()) * chunkWidth;
//+1 is b/c QRect assums boundries don't overlap when they do. Causes issues w/
//deposit placement.
return QRect(left, up, chunkWidth + 1, chunkWidth + 1);
}
示例12:
Foam::point Foam::scaleSearchableSurface::inverseTransform(const point &p) const
{
return point
(
p.x()/scale_.x(),
p.y()/scale_.y(),
p.z()/scale_.z()
);
}
开发者ID:Unofficial-Extend-Project-Mirror,项目名称:openfoam-extend-Breeder1.7-libraries-swak4Foam,代码行数:9,代码来源:scaleSearchableSurface.C
示例13: draw_text
void draw_text ( point origin, std::string text )
{
XDrawString ( m_display,
m_window_id,
m_gc,
origin.x(),
origin.y(),
text.c_str(),
text.size() );
}
示例14: z
point horizontalVelocityField::initialPositionOf
(
const point& p,
const Time& t
) const
{
const dimensionedScalar z("z", dimLength, p.z());
if (z.value() <= z1.value())
{
return p;
}
else if (z.value() <= z2.value())
{
return point(p.x() - (u0*sqr(Foam::sin(0.5*M_PI*(z-z1)/(z2-z1)))*t).value(), p.y(), p.z());
}
else
{
return point(p.x() - u0.value()*t.value(), p.y(), p.z());
}
}
示例15: forAll
forAll(order, sortI)
{
label pointI = order[sortI];
// Convert to scalar precision
const point pt
(
scalar(d[pointI].x()),
scalar(d[pointI].y()),
scalar(d[pointI].z())
);
sortedTol[sortI] = 2*mergeTol*(mag(pt.x())+mag(pt.y())+mag(pt.z()));
}