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


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

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


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

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

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

示例3:

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

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

示例5: main

#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));
	REQUIRE(kreis.getCenter().getX() == Approx(0.5));
开发者ID:iamfd,项目名称:fensterchen,代码行数:31,代码来源:tests.cpp

示例6:

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


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