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


C++ Point2D::setY方法代码示例

本文整理汇总了C++中Point2D::setY方法的典型用法代码示例。如果您正苦于以下问题:C++ Point2D::setY方法的具体用法?C++ Point2D::setY怎么用?C++ Point2D::setY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Point2D的用法示例。


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

示例1: xmlToPoint

Point2D XMLtoVecteur::xmlToPoint(TiXmlElement* p) 
{
	Point2D point;
	
	double x;
	if (p->QueryDoubleAttribute("x",&x) == TIXML_SUCCESS)
	{
		point.setX(x);
	}
	else
	{
		point.setX(0.0);
	}
	
	double y;
	if (p->QueryDoubleAttribute("y",&y) == TIXML_SUCCESS)
	{
		point.setY(y);
	}
	else
	{
		point.setY(0.0);
	}

	
	//cout << p->GetText() << endl;
	point.setNom(p->GetText());

	return point;
}
开发者ID:DepretA,项目名称:vecteur-xml,代码行数:30,代码来源:XMLtoVecteur.cpp

示例2: testDistanceBetween

void testDistanceBetween() {
  Point2D firstPoint;
  firstPoint.setX(3);
  firstPoint.setY(5);

  Point2D secondPoint;
  secondPoint.setX(4);
  secondPoint.setY(1);

  cout << firstPoint.distanceTo(secondPoint) << '\n';
}
开发者ID:dimitaruzunov,项目名称:oop-practicum-2015-16,代码行数:11,代码来源:point_2d_v3.cpp

示例3:

Point2D Point2D::operator - (const Point2D &other) const
{
    Point2D temp;
    temp.setX(this->x - other.x);
    temp.setY(this->y - other.y);
    return temp;
}
开发者ID:v3c70r,项目名称:GL2Curves,代码行数:7,代码来源:point2D.cpp

示例4: testTranslate

void testTranslate() {
  Point2D point;
  point.setX(3);
  point.setY(5);

  point.translate(2, 3);
  point.print();
}
开发者ID:dimitaruzunov,项目名称:oop-practicum-2015-16,代码行数:8,代码来源:point_2d_v3.cpp

示例5: checkBoxes

bool Monster::checkBoxes(std::vector<CollisionBox>* boxes, float p_x, float p_y){
	CollisionBox box;

	Point2D A = Point2D(this->getX(), this->getY());
	Point2D B;
	for (int i = 0; i < boxes->size(); i++){
		box = boxes->at(i);


		if (box.getRight() < this->getBox().getLeft())
			B.setX(box.getRight());
		else if (box.getLeft() > this->getBox().getRight())
			B.setX(box.getLeft());
		else
			B.setX(this->getX());

		if (box.getTop() < this->getBox().getBottom())
			B.setY(box.getTop());
		else if (box.getBottom() > this->getBox().getTop())
			B.setY(box.getBottom());
		else
			B.setY(this->getY());


		float difx = (B.getX() - A.getX()) * (B.getX() - A.getX());
		float dify = (B.getY() - A.getY()) * (B.getY() - A.getY());

		float dist = difx + dify;
		if (dist <= this->getRadius() * this->getRadius()){


			if ((this->getBox().getBottom() > box.getTop() ||
				this->getBox().getTop() < box.getBottom())
				){
				if (this->getBox().getBottom() > box.getTop()){
					if (p_x == this->getX()){
						this->angle = 0;
					}

					else if (p_x > this->getX()){

						if (this->getY() < p_y)
							this->angle = 8;
						else
							this->angle = 0;

					}
					else {

						if (this->getY() < p_y)
							this->angle = 172;
						else
							this->angle = 180;
					}

				}
				else if (this->getBox().getTop() < box.getBottom()){
					if (p_x == this->getX()){
						this->angle = 0;
					}

					else if (p_x > this->getX()){
						if (this->getY() > p_y)
							this->angle = 352;
						else
							this->angle = 0;

					}
					else{
						if (this->getY() > p_y)
							this->angle = 188;
						else
							this->angle = 180;
					}
				}

			}
			else if ((this->getBox().getRight() < box.getLeft() || this->getBox().getLeft() > box.getRight())
				){

				float up = box.getTop() - this->getY();
				float down = this->getY() - box.getBottom();

				if (this->getBox().getRight() < box.getLeft()){
					if (p_y == this->getY()){
						this->angle = 90;
					}
					else if (p_y > this->getY()){
						if (this->getX() > p_x)
							this->turn(this->getX() - 16, box.getTop() + 32);
						else
							this->turn(this->getX(), box.getTop() + 32);
					}
					else{
						if (this->getX() > p_x)
							this->turn(this->getX() - 16, box.getBottom() - 32);
						else
							this->turn(this->getX(), box.getBottom() - 32);
					}

//.........这里部分代码省略.........
开发者ID:berenkusmenoglu,项目名称:Pixel-Ninja,代码行数:101,代码来源:Monster.cpp

示例6:

//Computes the Fresnel integrals S(x) and C(x) for all real x
Point2D<double> EulerSpiral::get_fresnel_integral(double x)
{
    bool odd;
    int k,n;
    double a,ax,fact,pix2,sign,sum,sumc,sums,term,test;

    std::complex<double> b,cc,d,h,del,cs;
    Point2D<double> result;

    ax=fabs(x);
    if (ax < sqrt(FPMIN))
    {
        //Special case: avoid failure of convergence test because of undeflow.
        result.setY(0.0);
        result.setX(ax);
    }
    else {
        if (ax <= XMIN)
        {
            // Evaluate both series simultaneously.
            sum=sums=0.0;
            sumc=ax;
            sign=1.0;
            fact=(M_PI/2.0)*ax*ax;
            odd=true;
            term=ax;
            n=3;

            for (k=1; k<=MAXIT; k++)
            {
                term *= fact/k;
                sum  += sign*term/n;
                test=fabs(sum)*EPS;
                if (odd)
                {
                    sign = -sign;
                    sums=sum;
                    sum=sumc;
                }
                else {
                    sumc=sum;
                    sum=sums;
                }

                if (term < test) break;
                odd=!odd;
                n +=2;
            }

            if (k > MAXIT)
                std::cout << "series failed in fresnel" << std::endl;

            result.setY(sums);
            result.setX(sumc);
        }
        else {
            // Evaluate continued fraction by modified Lentz's method
            pix2=M_PI*ax*ax;
            b   = std::complex<double>(1.0,-pix2);
            cc  = std::complex<double>(1.0/FPMIN,0.0);
            d=h = std::complex<double>(1.0,0.0)/b;
            n = -1;

            for (k=2; k<=MAXIT; k++)
            {
                n +=2;
                a = -n*(n+1);
                b= b+std::complex<double>(4.0,0.0);
                d=(std::complex<double>(1.0,0.0)/((a*d)+b));

                //Denominators cannot be zero
                cc=(b+(std::complex<double>(a,0.0)/cc));

                del=(cc*d);
                h=h*del;
                if ((fabs(del.real()-1.0)+fabs(del.imag())) < EPS)
                    break;
            }
            if (k > MAXIT)
                std::cout << "cf failed in frenel" << std::endl;

            h=std::complex<double>(ax,-ax)*h;
            cs=std::complex<double>(0.5,0.5)*(std::complex<double>(1.0,0.0) - std::complex<double>(cos(0.5*pix2),sin(0.5*pix2))*h );

            result.setX(cs.real());
            result.setY(cs.imag());
        }
    }

    if (x<0) { //use antisymmetry
        result = -1*result;
    }

    return result;
}
开发者ID:aarongolliver,项目名称:sumo,代码行数:96,代码来源:euler.cpp

示例7: stepFindExactEyes

bool StudentLocalization::stepFindExactEyes(const IntensityImage &image, FeatureMap &features) const {

   int temp = 0;
	ImageIO::saveIntensityImage(image, ImageIO::getDebugFileName("input.png"));

	IntensityImageStudent copy(image);

	double** d_kern = new double*[3];
	for (int y = 0; y < 3; y++) {
		d_kern[y] = new double[3];
	}
	d_kern[0][0] = 0; 
	d_kern[0][1] = 1;
	d_kern[0][2] = 0;
	d_kern[1][0] = 1;
	d_kern[1][1] = 0;
	d_kern[1][2] = 1;
	d_kern[2][0] = 0;
	d_kern[2][1] = 1;
	d_kern[2][2] = 0;

	StudentKernel dilation = StudentKernel(d_kern, 3, 3, 0);

   Feature top = features.getFeature(Feature::FEATURE_HEAD_TOP);
   Feature bottom = features.getFeature(Feature::FEATURE_CHIN);
	Feature nose_bottom = features.getFeature(Feature::FEATURE_NOSE_BOTTOM);
	Feature headsideleft = features.getFeature(Feature::FEATURE_HEAD_LEFT_SIDE);
	Feature headsideright = features.getFeature(Feature::FEATURE_HEAD_RIGHT_SIDE);

   const int nose_to_top = nose_bottom.getY() - top.getY();

#if UNNECESSARY_CODE
#endif
	Point2D<double> headsidelp = headsideleft.getPoints()[0];
	headsidelp.setY(top.getY() + (nose_to_top*3/5));
	headsidelp.setX((headsidelp.getX()));


	Point2D<double> headsiderp = headsideright.getPoints()[0];
   headsiderp.setY(nose_bottom.getY() - (nose_to_top*1/5));
	headsiderp.setX((headsiderp.getX() + 3));


   IntensityImageStudent eyes = ImageUtils::subimage(&image, headsidelp, headsiderp);
	IntensityImageStudent eyes_dilated = dilation.dilate(&eyes);

   StudentHistogram histo{eyes_dilated.getWidth()};
   int zero_points[2] = { 0, histo.get_length() * 1 / 7 };
   int lowest_found[2] = { eyes_dilated.getHeight(), eyes_dilated.getHeight() };

   int left_out = 0, left_out_x = 0,
       right_out = 0, right_out_x = 0,
       left_in = 0, left_in_x = 0,
       right_in = 0, right_in_x = 0;

   for (int x = 0; x < histo.get_length(); x++){
       temp = 0;
       for (int y = 0; y < eyes_dilated.getHeight(); y++){
           temp += eyes_dilated.getPixel(x, y) > 127 ? 0 : 1;
       }
       histo.set_value(x, temp);
       if (x < histo.get_length() * 3 / 10 && temp <= lowest_found[0]){
           lowest_found[0] = temp;
           zero_points[0] = x;
       }
       if (x > histo.get_length() * 7 / 10 && temp < lowest_found[1]){
           lowest_found[1] = temp;
           zero_points[1] = x;
       }
   }

   headsidelp.setX(headsidelp.getX() + zero_points[0]);
   headsiderp.setX(headsiderp.getX() - (histo.get_length() - zero_points[1]));

   headsidelp.setY(top.getY() + (nose_to_top * 2/ 5));
   headsiderp.setY(nose_bottom.getY());

   IntensityImageStudent eyes2(ImageUtils::subimage(&image, headsidelp, headsiderp));
   IntensityImageStudent eyes_copy2(dilation.dilate(&eyes2));

   histo.cut_to_size(zero_points[0], zero_points[1]);
   for (int x = 0; x < histo.get_length(); x++){
       if (x < histo.get_length() * 2 / 9){
           left_out_x = histo.get_value(x) > left_out ? x : left_out_x;
           left_out = histo.get_value(x) > left_out ? histo.get_value(x) : left_out;
       }
       else if (x < histo.get_length() * 4 / 9 && x > histo.get_length() * 2 / 9){
           left_in_x = histo.get_value(x) > left_in ? x : left_in_x;
           left_in = histo.get_value(x) > left_in ? histo.get_value(x) : left_in;
       }
       else if (x > histo.get_length() * 7 / 9){
           right_out_x = histo.get_value(x) > right_out ? x : right_out_x;
           right_out = histo.get_value(x) > right_out ? histo.get_value(x) : right_out;
       }
       else if (x > histo.get_length() * 5 / 9){
           right_in_x = histo.get_value(x) > right_in ? x : right_in_x;
           right_in = histo.get_value(x) > right_in ? histo.get_value(x) : right_in;
       }
   }

//.........这里部分代码省略.........
开发者ID:flammified,项目名称:HU-Vision-1516-BestName2016,代码行数:101,代码来源:StudentLocalization.cpp

示例8: main


//.........这里部分代码省略.........
		window.DrawLineInSpace(p55, p56);
		window.DrawLineInSpace(p56, p57);
		window.DrawLineInSpace(p57, p54);
		window.DrawLineInSpace(p50, p54);
		window.DrawLineInSpace(p51, p55);
		window.DrawLineInSpace(p52, p56);
		window.DrawLineInSpace(p53, p57);

		window.DrawLineInSpace(p60, p61);
		window.DrawLineInSpace(p61, p62);
		window.DrawLineInSpace(p62, p63);
		window.DrawLineInSpace(p63, p60);
		window.DrawLineInSpace(p64, p65);
		window.DrawLineInSpace(p65, p66);
		window.DrawLineInSpace(p66, p67);
		window.DrawLineInSpace(p67, p64);
		window.DrawLineInSpace(p60, p64);
		window.DrawLineInSpace(p61, p65);
		window.DrawLineInSpace(p62, p66);
		window.DrawLineInSpace(p63, p67);


		//window.DrawLineInSpace(p40, p41);
		window.DrawLineInSpace(p41, p42);
		window.DrawLineInSpace(p42, p43);
		//window.DrawLineInSpace(p43, p40);
		//window.DrawLineInSpace(p44, p45);
		window.DrawLineInSpace(p45, p46);
		//window.DrawLineInSpace(p46, p47);
		//window.DrawLineInSpace(p47, p44);
		window.DrawLineInSpace(p40, p45);
		window.DrawLineInSpace(p41, p45);
		window.DrawLineInSpace(p42, p46);
		window.DrawLineInSpace(p43, p47);
		window.DrawLineInSpace(p40, p47);
		window.DrawLineInSpace(p41, p49);
		window.DrawLineInSpace(p42, p49);
		window.DrawLineInSpace(p41, p48);
		window.DrawLineInSpace(p45, p48);


				if(GetAsyncKeyState(VK_DOWN)) // the DOWN arrow was pressed, let's do something
		{
		delta = -.1;
		viewPos.setY(viewPos.getY() + cos(-viewDir.getAngle())*delta);
		viewPos.setX(viewPos.getX() + sin(-viewDir.getAngle())*delta);
		window.SetViewPosition(viewPos);
		cout << "view pos: " << viewPos.toString() << endl;

		window.DisplayNow();
		Sleep(50);
				}

			if(GetAsyncKeyState(VK_UP)) // the UP arrow was pressed, let's do something
		{
		delta = .1;
		viewPos.setY(viewPos.getY() + cos(-viewDir.getAngle())*delta);
		viewPos.setX(viewPos.getX() + sin(-viewDir.getAngle())*delta);
		window.SetViewPosition(viewPos);
		cout << "view pos: " << viewPos.toString() << endl;

		window.DisplayNow();
		Sleep(50);
				}
				if(GetAsyncKeyState(VK_RIGHT)) // the RIGHT arrow was pressed, let's do something
		{
	
		delta = .1;

		viewDir.setAngle(viewDir.getAngle()+delta);
		window.SetViewDirection(viewDir);
		cout << "view dir: " << viewDir.getAngle() << endl;

		window.DisplayNow();
		Sleep(50);	
			}
			
			if(GetAsyncKeyState(VK_LEFT)) // the LEFT arrow was pressed, let's do something
		{
	
		delta = -.1;

		viewDir.setAngle(viewDir.getAngle()+delta);
		window.SetViewDirection(viewDir);
		cout << "view dir: " << viewDir.getAngle() << endl;

		window.DisplayNow();
		Sleep(50);	
			}

		if(GetAsyncKeyState(VK_ESCAPE))
		{
			return 1;
		}
	}


		
	
}
开发者ID:laughingMan,项目名称:CS-325,代码行数:101,代码来源:cs325graphicsdriver.cpp


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