当前位置: 首页>>代码示例>>C++>>正文


C++ point::x方法代码示例

本文整理汇总了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));
}
开发者ID:mohlek,项目名称:game-of-life,代码行数:29,代码来源:line.cpp

示例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;
}
开发者ID:nordic-robotics,项目名称:nord_estimation,代码行数:7,代码来源:map.cpp

示例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));
}
开发者ID:null0000,项目名称:MOV,代码行数:18,代码来源:scChunkManager.cpp

示例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
			){}
开发者ID:bebuch,项目名称:disposer_module,代码行数:12,代码来源:rect.hpp

示例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;
 }
开发者ID:null0000,项目名称:MOV,代码行数:9,代码来源:scChunkManager.cpp

示例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
}
开发者ID:frandibar,项目名称:acm-valladolid,代码行数:10,代码来源:acm.cpp

示例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();
	}
开发者ID:bebuch,项目名称:disposer_module,代码行数:10,代码来源:rect.hpp

示例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);
}
开发者ID:hczhu,项目名称:TC-code,代码行数:11,代码来源:IsoscelesTriangles.cpp

示例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;
    }
}
开发者ID:CFMS,项目名称:foam-extend-foam-extend-3.2,代码行数:35,代码来源:octreeDataBoundBox.C

示例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;
    }
}
开发者ID:AtmosFOAM,项目名称:AtmosFOAM-tools,代码行数:27,代码来源:arakawaKonorStripes.C

示例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);
}
开发者ID:null0000,项目名称:MOV,代码行数:8,代码来源:scChunkManager.cpp

示例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() );
	}
开发者ID:8l,项目名称:x11,代码行数:10,代码来源:graphics_context.hpp

示例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());
    }
}
开发者ID:AtmosFOAM,项目名称:AtmosFOAM-tools,代码行数:21,代码来源:horizontalVelocityField.C

示例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()));
    }
开发者ID:Kiiree,项目名称:CONSELFcae-dev,代码行数:13,代码来源:mergePoints.C


注:本文中的point::x方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。