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


C++ Point2d::getX方法代码示例

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


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

示例1: intersects

/**
 * This is a helper function which calls the Line->intersect method and adds a new Event.
 */
bool SLIntersectionTest::intersects( Line * a, Line * b ) {
  Point2d * intersection = new Point2d;
  pair<multimap<float, SLEvent *>::iterator,
      multimap<float, SLEvent *>::iterator> range; // a pair of iterators. the return value of multimap.equal_range
  multimap<float, SLEvent *>::iterator it;

  if( ( a )->intersect( b, *intersection ) ) {

    //search if intersection already exists in xstruct.
    range = xStruct.equal_range( intersection->getX() );

    //whats that? Don't know, maybe check if we had the intersection already.
    for( it = range.first; it != range.second; it++ ) {
      if( ( it->second->getType() == INTERSECTION )
          && ( it->second->getCoords() == *intersection )
          && ( ( it->second->getLines()[0] == a )
              || ( it->second->getLines()[0] == b ) )
          && ( ( it->second->getLines()[1] == a )
              || ( it->second->getLines()[1] == b ) ) ) {
        return false;
      }
    }

    xStruct.insert(
        pair<float, SLEvent *>( intersection->getX(),
            new SLEvent( INTERSECTION, *intersection, *a, *b ) ) );
    return true;
  }
  return false;
}
开发者ID:twaldecker,项目名称:Computational-Geometry-Praktikum,代码行数:33,代码来源:SLIntersectionTest.cpp

示例2: alignToGrid

void LevelDesignerController::alignToGrid(void) {
  PolygonList polygonList = _model->getPolygonList();
  for (int k = 0; k < _model->rowCount(); ++k) {
    TreeItem* polygonItem = _model->getItem(_model->index(k, 0));
    std::vector<Point2d> vertices = polygonList.at(k).getVertices();
    for (int i = 0; i < polygonItem->childCount(); ++i) {
      Point2d currVertex = vertices.at(i);

      int oldX = currVertex.getX();
      int oldY = currVertex.getY();

      int extraX = static_cast<int>(oldX)%50;
      int extraY = static_cast<int>(oldY)%50;

      int newX = oldX;
      int newY = oldY;

      if (extraY < 50/3)
        newY = oldY - extraY;// + 5;
      else if (extraY > 50 - 50/3)
        newY = oldY + (50 - extraY);// + 5;

      if (extraX < 50/3)
        newX = oldX - extraX;// + 5;
      else if (extraX > 50 - 50/3)
        newX = oldX + (50 - extraX);// + 5;

      if (oldX != newX || oldY != newY)
        moveVertex(k, i, oldX, oldY, newX, newY);
    }
  }
}
开发者ID:vmichele,项目名称:PieceOfCake,代码行数:32,代码来源:LevelDesignerController.cpp

示例3: applyLocalWindow

	// transform the mouse (Window coordinates) to the local coordinates (accordingly to localScreen matrix)
	// reference (local coordinates) is required to set the depth of the mouse cursor in screen
Point3d ViewportUtil::applyLocalWindow(const Point2d &mouse,const Point3d &reference) {
		Point4d ref4d(reference);
		normalizedLocal.transform(&ref4d);
		Point4d result4d(mouse.getX(),mouse.getY(),ref4d.getZ()/ref4d.getW(),1.0);
		localWindow.transform(&result4d);
		Point3d result;
		result.project(result4d);
		return result;
	}
开发者ID:vidma,项目名称:snowman-game-3d,代码行数:11,代码来源:ViewportUtil.cpp

示例4:

double Segment::distance2(const Point2d &p) {
		return distance2(Point3d(p.getX(),p.getY(),0));
}
开发者ID:vidma,项目名称:snowman-game-3d,代码行数:3,代码来源:Segment.cpp

示例5: setAB

void Segment::setAB(const Point2d &aa,const Point2d &bb) {
		a.set(aa.getX(),aa.getY(),0);
		b.set(bb.getX(),bb.getY(),0);
}
开发者ID:vidma,项目名称:snowman-game-3d,代码行数:4,代码来源:Segment.cpp

示例6: main

#include <catch.hpp>
#include <color.hpp>
#include <point2d.hpp>
#include <circle.hpp>
#include <rectangle.hpp>
#define _USE_MATH_DEFINES
#include <cmath>

int main(int argc, char *argv[])
{
  return Catch::Session().run(argc, argv);
}

TEST_CASE("describe_test", "[test]"){
	Point2d punkt{0.5, 1.0};
	REQUIRE(punkt.getX() == Approx(0.5));
	REQUIRE(punkt.getY() == Approx(1.0));
	Point2d punkt2{1.0, 1.0};
	punkt2.translate(-2.0, -2.0);
	REQUIRE(punkt2.getX() == Approx(-1.0));
	REQUIRE(punkt2.getY() == Approx(-1.0));
	punkt2.rotate(M_PI);
	REQUIRE(punkt2.getX() == Approx(1.0));
	REQUIRE(punkt2.getY() == Approx(1.0));


	Color farbe{1.0, 0.0, 0.0};
	Circle kreis{punkt, 2.0, farbe};
	REQUIRE(kreis.getRadius() == Approx(2.0));
	REQUIRE(kreis.circumference() == Approx(12.56637));
	REQUIRE(kreis.getColor().r == Approx(1.0));
开发者ID:iamfd,项目名称:fensterchen,代码行数:31,代码来源:tests.cpp

示例7:

inline Point2dFloat operator*(const Point2d pt, const float factor)
{
	return Point2dFloat(pt.getX() * factor, pt.getY() * factor);
}
开发者ID:jannickep,项目名称:snowbots,代码行数:4,代码来源:Point2dFloat.hpp


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