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


C++ Point::GetX方法代码示例

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


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

示例1: GetDeviationAngle

double Line::GetDeviationAngle(const Line &l) const {
    // const double PI = 3.14159258;
#define DEBUG 0
    Point P = _point1;
    Point Goal = _point2;

    Point L = l._point1;
    Point R = l._point2;

    double dist_Goal_L = (Goal - L).NormSquare();
    double dist_Goal_R = (Goal - R).NormSquare();

    double angle, angleL, angleR;
    // we don't need to calculate both angles, but for debugging purposes we do it.
    angleL = atan((Goal - P).CrossProduct(L - P) / (Goal - P).ScalarProduct(L - P));
    angleR = atan((Goal - P).CrossProduct(R - P) / (Goal - P).ScalarProduct(R - P));

    angle = (dist_Goal_L < dist_Goal_R) ? angleL : angleR;
#if DEBUG
     printf("Enter GetAngel()\n");
     printf("\tP=[%f,%f]\n",P.GetX(), P.GetY());
     printf("\tGoal=[%f,%f]\n",Goal.GetX(), Goal.GetY());
     printf("\tL=[%f,%f]\n",L.GetX(), L.GetY());
     printf("\tR=[%f,%f]\n",R.GetX(), R.GetY());
     printf("\t\tdist_Goal_L=%f\n",dist_Goal_L);
     printf("\t\tdist_Goal_R=%f\n",dist_Goal_R);
     printf("\t\t --> angleL=%f\n",angleL);
     printf("\t\t --> angleR=%f\n",angleR);
     printf("\t\t --> angle=%f\n",angle);
     printf("Leave GetAngel()\n");
#endif
    return angle;
}
开发者ID:JuPedSim,项目名称:jpsreport,代码行数:33,代码来源:Line.cpp

示例2: Hits

// ------------------------------------------------------------------------------------------------------ PUBLIC METHODS
    //Public methods
    const bool Rectangle::Hits(Point aPoint)
    {
        return(
                ((aPoint.GetX()>=points[0].GetX() && aPoint.GetX()<=points[1].GetX()) || (aPoint.GetX()<=points[0].GetX() && aPoint.GetX()>=points[1].GetX()))
        &&
                ((aPoint.GetY()>=points[0].GetY() && aPoint.GetY()<=points[1].GetY()) || (aPoint.GetY()<=points[0].GetY() && aPoint.GetY()>=points[1].GetY()))
        );
    }
开发者ID:Xaxetrov,项目名称:Tpp-Cpp-5,代码行数:10,代码来源:Rectangle.cpp

示例3: fncomp

bool fncomp (Point lhs, Point rhs) 
{if(lhs.GetX()<rhs.GetX())return true;
  else if(lhs.GetX()==rhs.GetX())
  {
       if(lhs.GetY()<rhs.GetY())return true;
       else return false;
  }
  else return false;
}
开发者ID:sagarc,项目名称:Location-Finder,代码行数:9,代码来源:main.cpp

示例4: DrawWall

void DrawWall(Point color, Point a, Point b, Point c, Point d)
{
  GLfloat mat_amb_diff[] = { color.GetX(), color.GetY(), color.GetZ(), 1.0 };
  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_amb_diff);
  glBegin(GL_QUADS);
  glVertex3f(a.GetX(), a.GetY(), a.GetZ());
  glVertex3f(b.GetX(), b.GetY(), b.GetZ());
  glVertex3f(c.GetX(), c.GetY(), c.GetZ());
  glVertex3f(d.GetX(), d.GetY(), d.GetZ());
  glEnd();
}
开发者ID:spillow,项目名称:Samples,代码行数:11,代码来源:main.cpp

示例5: intersect

Point intersect(float t, Point A, Point B)
{
    // [AB] : Q(t) = (1 - t)A + tB, 0 <= t <= 1

    Point I;
    Point tmpA = Point((1 - t) * A.GetX(), (1 - t) * A.GetY());
    Point tmpB = Point(t * B.GetX(), t * B.GetY());

    I = tmpA + tmpB;

    return I;
}
开发者ID:Ometeo,项目名称:Math,代码行数:12,代码来源:main.cpp

示例6: Contains

bool Rectangle::Contains(const Point& point) const
{
	if((point.GetX() >= GetX()) && (point.GetX() <= (GetX() + GetWidth())))
	{
		if((point.GetY() >= GetY()) && (point.GetY() <= (GetY() + GetHeight())))
		{
			return true;
		}
	}
	
	return false;
}
开发者ID:Fissuras,项目名称:mugenformation,代码行数:12,代码来源:Rectangle.cpp

示例7: RotateSecondPoint

void MCircle::RotateSecondPoint(Point i_center, double i_angle)
  {
  double pi = 3.141592654;
  double angle = (i_angle)* (pi / 180);
  double rotated_x = cos(angle) * (m_second_point.GetX() - i_center.GetX()) -
    sin(angle) * (m_second_point.GetY() - i_center.GetY()) + i_center.GetX();

  double rotated_y = sin(angle) * (m_second_point.GetX() - i_center.GetX()) +
    cos(angle) * (m_second_point.GetY() - i_center.GetY()) + i_center.GetY();

  m_second_point.SetX(rotated_x);
  m_second_point.SetY(rotated_y);
  }
开发者ID:khalidcawl,项目名称:Drawing-Application,代码行数:13,代码来源:MCircle.cpp

示例8: Appartient

bool Rectangle::Appartient( Point p)
// Algorithme :
//
{
	if ( p.GetX() >= listePoints.front().GetX() && p.GetX() <= listePoints.back().GetX()
		&& p.GetY() >= listePoints.front().GetY() && p.GetY() <= listePoints.back().GetY())
	{
		return true;
	}
	else
	{
		return false;
	}
} //----- Fin de Appartient
开发者ID:samoryka,项目名称:TPB3430,代码行数:14,代码来源:Rectangle.cpp

示例9: SetPoint

void Point::SetPoint(Point point)
{
    float x = point.GetX();
    float y = point.GetY();
    
    SetPoint(x, y);
}
开发者ID:Harashen,项目名称:ArcadEngine,代码行数:7,代码来源:point.cpp

示例10: main

void main()

{
	Point a;
	Point b(2, 3);
	cout << a.GetX() << "  " << a.GetY() << endl;
	cout << b.GetX() << "  " << b.GetY() << endl;

	a.SetX(9);
	a.SetY(-9);
	cout << a.GetX() << "  " << a.GetY() << endl;

	Point * p = new Point(1, 7);
	cout << p->GetX() << "  " << p->GetY() << endl;
	delete p;
}
开发者ID:KhvedY,项目名称:Cat,代码行数:16,代码来源:Point.cpp

示例11:

TEST(PointTest, TranslateYMovesPointInNegativeYDirection)
{
	Point p;
	p.TranslateY(-2);
	EXPECT_EQ(0, p.GetX());
	EXPECT_EQ(-2, p.GetY());
}
开发者ID:thomasplain,项目名称:arkanoids,代码行数:7,代码来源:Point_UnitTests.cpp

示例12: Appartient

bool Segment::Appartient( Point p )
// Algorithme :
// On vérifie que les extrémités du segment et p sont alignés (produit vectoriel),
// puis que p se trouve bien entre elles (produit scalaire + vérification de norme).
{
	// On définit des "points" représentant en fait les coodonnées de vecteurs
	// utilisés pour le calcul
	Point petitX_grandX = Point(
			listePoints.back().GetX() - listePoints.front().GetX(),
			listePoints.back().GetY() - listePoints.front().GetY() );

	Point petitX_p = Point( p.GetX() - listePoints.front().GetX(),
			p.GetY() - listePoints.front().GetY() );

	int comparaisonNormesCarrees = petitX_grandX.GetX() * petitX_grandX.GetX()
			+ petitX_grandX.GetY() * petitX_grandX.GetY()
			- petitX_p.GetX() * petitX_p.GetX()
			- petitX_p.GetY() * petitX_p.GetY();

	if ( petitX_grandX.ProduitVectoriel( petitX_p ) == 0
			&& petitX_grandX.ProduitScalaire( petitX_p ) >= 0
			&& comparaisonNormesCarrees >= 0 )
	{
		return true;
	}
	else
	{
		return false;
	}
} //----- Fin de Appartient
开发者ID:samoryka,项目名称:TPB3430,代码行数:30,代码来源:Segment.cpp

示例13: EqualPoints

bool Point::EqualPoints(Point point)
{
    float x = point.GetX();
    float y = point.GetY();
    
    if (x == mX && y == mY) return true;
    
    return false;
}
开发者ID:Harashen,项目名称:ArcadEngine,代码行数:9,代码来源:point.cpp

示例14: Distance

float Point::Distance(Point point)
{  
    float x = DistanceX(point.GetX());
    float y = DistanceY(point.GetY());

    y = abs(y);
    x = abs(x);
    
    return max(y, x);
}
开发者ID:Harashen,项目名称:ArcadEngine,代码行数:10,代码来源:point.cpp

示例15: IntersectionWithCircle

bool Line::IntersectionWithCircle(const Point &centre, double radius /*cm for pedestrians*/) {

    double r = radius;
    double x1 = _point1.GetX();
    double y1 = _point1.GetY();

    double x2 = _point2.GetX();
    double y2 = _point2.GetY();

    double xc = centre.GetX();
    double yc = centre.GetY();

    //this formula assumes that the circle is centered the origin.
    // so we translate the complete stuff such that the circle ends up at the origin
    x1 = x1 - xc;
    y1 = y1 - yc;
    x2 = x2 - xc;
    y2 = y2 - yc;
    //xc=xc-xc;yc=yc-yc; to make it perfect

    // we first check the intersection of the circle and the  infinite line defined by the segment
    double dr2 = ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
    double D2 = (x1 * y2 - x2 * y1) * (x1 * y2 - x2 * y1);
    double r2 = radius * radius;

    double delta = r2 * dr2 - D2;
    if (delta <= 0.0) return false;


    double a = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
    double b = 2 * ((x1 * (x2 - x1)) + y1 * (y2 - y1));
    double c = x1 * x1 + y1 * y1 - r * r;

    delta = b * b - 4 * a * c;

    if ((x1 == x2) && (y1 == y2)) {
        Log->Write("isLineCrossingCircle: Your line is a point");
        return false;
    }
    if (delta < 0.0) {
        char tmp[CLENGTH];
        sprintf(tmp, "there is a bug in 'isLineCrossingCircle', delta(%f) can t be <0 at this point.", delta);
        Log->Write(tmp);
        Log->Write("press ENTER");
        return false; //fixme
        //getc(stdin);
    }

    double t1 = (-b + sqrt(delta)) / (2 * a);
    double t2 = (-b - sqrt(delta)) / (2 * a);
    if ((t1 < 0.0) || (t1 > 1.0)) return false;
    if ((t2 < 0.0) || (t2 > 1.0)) return false;
    return true;
}
开发者ID:JuPedSim,项目名称:jpsreport,代码行数:54,代码来源:Line.cpp


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