• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ point类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中point的典型用法代码示例。如果您正苦于以下问题:C++ point类的具体用法?C++ point怎么用?C++ point使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了point类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: calc_length

//
// Calculate the distance between two points.
//
float edge::calc_length( const point& a, const point& b )
{
	int dx = a.get_x() - b.get_x();
	int dy = a.get_y() - b.get_y();
	return static_cast<float>(
			std::sqrt( static_cast<double>( dx * dx + dy * dy ) ) );
}
开发者ID:crithead,项目名称:mst,代码行数:10,代码来源:edge.cpp


示例2: main

int main() {
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	int i,j,k;
	int n,r;
	int CA=0;
	while ( ~scanf ( "%d%d",&n,&r ) ) {
		vector<point>P;
		for ( i=0; i<n; i++ ) {
			point foo;
			foo.in();
			P.PB ( foo );
		}
//		P=ConvexHull(P);
		if ( !P.empty() ) P.PB ( P[0] );
		for(nl=0,i=1;i<P.SZ;i++){
			point s=P[i],e=P[i-1];
			point d=(e-s).rotate().normal()*r;
			L[nl++]=line(s+d,e+d);
		}
		nr=HPI(L,nl,R);
		P.clear();
		for(i=0;i<nr;i++)P.PB(R[i]);
		P=ConvexHull(P);
		ConvecDiameter(P);
		if(sign(au.x-av.x)>0)swap(au,av);
		au.out(" ");
		av.out("\n");
	}
	return 0;
}
开发者ID:JintianGo,项目名称:Training,代码行数:31,代码来源:3384.cpp


示例3: 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


示例4: cmp

bool cmp(point left, point right) {
    point a = left - points[0], b = right - left;
    if(a.x * b.y > b.x * a.y) return 1;
    if(a.x * b.y == b.x * a.y)
        return left.len() < right.len();
    return 0;
}
开发者ID:CoderINusE,项目名称:Algorithms-data-structues,代码行数:7,代码来源:convex-hull.cpp


示例5: tour

bool tour(int board[8][8],point posNew,int step){
    int x = posNew.getx();
    int y = posNew.gety();
    
    if (step==64) {
        return true;
    }
    bool result;
    for (int k=0; k<8; k++) {
        point p = move(x,y,k+1);
        int x1,y1;
        x1 = p.getx();
        y1 = p.gety();
        if (x1<8 && x1>=0 && y1<8 && y1>=0 && board[x1][y1]==-1) {
            board[x1][y1] = step;
            result = tour(board, p, step+1);
            if (result) {
                return true;
            }else{
                board[x1][y1]=-1;
            }
        }
    }
    return false;
}
开发者ID:JustDNA,项目名称:DSalgo,代码行数:25,代码来源:Rec&DP.cpp


示例6: miseAjour

/*cubeCol* joueur::getCube()
{
return &collision;
}*/
void joueur::miseAjour(point newPosition, uint16_t newAngleX, uint16_t newAngleY, uint8_t newGaz, uint8_t newAxeX, uint8_t newAxeY, float newVitesse)
{
if(newPosition.getX() > -251 && newPosition.getX() < 251 && newPosition.getY() > -251 && newPosition.getY() < 251 && newPosition.getZ() > -251 && newPosition.getZ() < 251)
{
position = newPosition;
}
if(newAngleX < 361)
{
angleX = newAngleX;
}
if(newAngleY < 361)
{
angleY = newAngleY;
}
if(newGaz == 0 || newGaz == 1)
{
gaz = newGaz;
}
if(newAxeX == 0 || newAxeX == 1 || newAxeX == 2 )
{
axeX = newAxeX;
}
if(newAxeY == 0 || newAxeY == 1 || newAxeY == 2 )
{
axeY = newAxeY;
}
if(newVitesse >= 0 && newVitesse <= vitesseMax)
{
vitesse = newVitesse;
}
}
开发者ID:Celarivers,项目名称:Celarivers,代码行数:35,代码来源:Vaisseau.cpp


示例7: calc

double calc(const point &a, const point &b) {
    point p[2];
    int num = 0;
    int ina = dcmp(a.norm()- r) < 0;
    int inb = dcmp(b.norm() - r) < 0;
    if (ina) {
        if (inb) {
            return fabs(det(a, b)) / 2;
        } else {
            circle_inter_line(a, b, point(0, 0), r, p, num);
            return sector_area(b, p[0]) + fabs(det(a, p[0])) / 2;
        }
    } else {
        if (inb) {
            circle_inter_line(a, b, point(0, 0), r, p, num);
            return sector_area(p[0], a) + fabs(det(p[0], b)) / 2;
        } else {
            circle_inter_line(a, b, point(0, 0), r, p, num);
            if (num == 2) {
                return sector_area(a, p[0]) + sector_area(p[1], b) + fabs(det(p[0], p[1])) / 2;
            } else {
                return sector_area(a, b);
            }
        }
    }
}
开发者ID:moretimes,项目名称:template,代码行数:26,代码来源:Geo.cpp


示例8: g

point minimization::calcGoMin(point p) {
    point g(p.size());
    for (int i = 0; i < (int)p.size()/* && Fcnt < 1e6*/; i++) {
        if (fabs(p[i] - FL->l0[i]) < eps) {
            point p1(p);
            p1[i] += eps1;
            g[i] = -(calcF(p1) - calcF(p)) / eps1;
            if (g[i] < 0) {
                g[i] = 0;       
            }
        } else
        if (fabs(p[i] - FL->r0[i]) < eps) {
            point p1(p);
            p1[i] -= eps1;
            g[i] = -(calcF(p) - calcF(p1)) / eps1;
            if (g[i] > 0) {
                g[i] = 0;       
            }
        } else {
            point p1(p);
            p1[i] += eps1;
            g[i] = -(calcF(p1) - calcF(p)) / eps1;            
        }
    }
    return g;
}
开发者ID:romanandreev,项目名称:FindMin,代码行数:26,代码来源:minimization.cpp


示例9: ikinAbs

void twoLinkArm::ikinAbs(point x, point &q)
{
	x=x-params.x0;
	double S=(std::pow(params.l1+params.l2,2)-(std::pow(x.X(),2)+std::pow(x.Y(),2)))/(std::pow(x.X(),2)+std::pow(x.Y(),2)-std::pow(params.l1-params.l2,2));
	q[1]=-2.0*std::atan(std::sqrt(std::abs(S))); //Negative sign indicates elbow right.
	q[0]=std::atan2(x.Y(),x.X())-std::atan2(params.l2*std::sin(q[1]),params.l1+params.l2*std::cos(q[1]));
}
开发者ID:ambivalentduck,项目名称:psychicRobot,代码行数:7,代码来源:arm.cpp


示例10: set_point

void line::set_point(point p1, point p2) {
	this->p1.set_x(p1.get_x());
	this->p1.set_y(p1.get_y());
	
	this->p2.set_x(p2.get_x());
	this->p2.set_y(p2.get_y());
}
开发者ID:husnimun,项目名称:Tugas-3-Grafika,代码行数:7,代码来源:line.cpp


示例11: while

Ship::Ship(point originPoint, direction o, int l) 
{
	origin = originPoint;
	orientation = o;
	length = l;	
	lencopy = length;
	hits = 0;

	points.add(originPoint);
	if (orientation == HORIZONTAL)
	{
		while((lencopy - 1) > 0)
		{
			points.add((originPoint.getX() + 1), originPoint.getY)
			lencopy -= 1;
		}
	}
	else
	{
		while((lencopy - 1) > 0)
		{
			points.add(originPoint.getX(), (originPoint.getY()+1))
			lencopy -= 1;
		}
	}
}
开发者ID:kcutler,项目名称:Cplus-Battleship,代码行数:26,代码来源:Ship.cpp


示例12: trackMouse

// Processes mouse movements for skeleton manipulation
void trackMouse(int x, int y)
{
    if(mode == 2 && selected >= joints.size())
    {
        point *s = &xydpoints.at(selected - joints.size());
        if(RM)
        {
            double shift = (clickpos.gety() - y)/50.;
            *s = point(s->getx(), s->gety(), clickpos.getz()+shift);
        }
        else
        {
            *s = point(x, y, s->getz());
        }
        setTargets();
    }
    else if(mode == 1)
    {
        if(LM && selected >= 0 && selected <= joints.size())
        {
            double shift = clickpos.gety() - y;
            joints.at(selected)->settheta(clickpos.getz() + shift);
        }
    }
}
开发者ID:bigrpg,项目名称:Kinematics,代码行数:26,代码来源:main.cpp


示例13: 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


示例14: origin

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


示例15: smaller_angle

bool smaller_angle(const point<2>& first_point, const point<2>& p1, const point<2>& p2) 
{
	if (collinear(first_point, p1, p2))
		return (first_point.square_distance(p1) > first_point.square_distance(p2));

	return (!ccw(first_point, p1, p2));
}
开发者ID:frandibar,项目名称:acm-valladolid,代码行数:7,代码来源:acm.cpp


示例16: vp

hash vp(const point& v1, const point& v2, const point& c){
	hash ret;
	ret.a = v1.dist(c);
	ret.b = v2.dist(c);
	ret.c = v1.dist(v2);
	return ret;
}
开发者ID:DrhF,项目名称:ACM,代码行数:7,代码来源:sol.cpp


示例17:

 inline void distanceTransform::sedMask::query_distance(point &shortest, 
                                                        point &other)const{
   if((other.x >= 0) &&
      ((shortest.x < 0) || (shortest.absSqr() > other.absSqr()))) {
     shortest = other;
   }
 }
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:7,代码来源:ltiDistanceTransform.cpp


示例18: printline

		void printline() //输出提示信息
		{
			p1.printpoint(); //调用对象成员的公共接口
			cout << "  ------->  ";
			p2.printpoint(); //调用对象成员的公共接口
			cout << endl;
		}
开发者ID:he3210,项目名称:wd,代码行数:7,代码来源:main.cpp


示例19: 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


示例20: checkNeighbors

bool checkNeighbors(point currentPoint, grid * theGrid) {
    int row = currentPoint.getRow();
    int column = currentPoint.getColumn();
    int currentValue = theGrid->getValue(row,column);
    int status;
    
    if (row != 0) { // Neighbor to the north (Canada)
        status = checkPosition(row-1, column, currentValue, theGrid);
        if (status == 99) return true;
        else if (status == 1) pointQueue.enqueue(point(row-1,column));
    }
    if (row < theGrid->getSize() -1) { // Neighbor to the south (Mexico)
        status = checkPosition(row+1, column, currentValue, theGrid);
        if (status == 99) return true;
        else if (status == 1) pointQueue.enqueue(point(row+1,column));
    }
    if (column != 0) { // Neighbor to the west (Pacific)
        status = checkPosition(row, column-1, currentValue, theGrid);
        if (status == 99) return true;
        else if (status == 1) pointQueue.enqueue(point(row,column-1));
    }
    if (column < theGrid->getSize() -1) { // Neighbor to the east (Atlantic)
        status = checkPosition(row, column+1, currentValue, theGrid);
        if (status == 99) return true;
        else if (status == 1) pointQueue.enqueue(point(row,column+1));
    }
    return false;
}
开发者ID:josh-jacobson,项目名称:wire_routing,代码行数:28,代码来源:Utilities.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pointField类代码示例发布时间:2022-05-31
下一篇:
C++ pod_vector类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap