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


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

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


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

示例1: spline

// Tests the version of the constructor that takes a vector of points
// with a small sample of points
TEST_F(SplineTest, constructor_from_points_small_case) {
    std::vector<Point2D> points = {{1, 1}, {3, 3}, {2, 4}, {5, 1}};
    Spline spline(points);

    // Check the start and end points of the spline
    // (ie. check that the spline passes through the start and end points)
    EXPECT_EQ(Point2D(1, 1), spline(0));
    EXPECT_EQ(Point2D(5, 1), spline(1));

    // Check the values at the interpolation points
    // (ie. check that the spline passes through the interpolation points)
    EXPECT_EQ(Point2D(3, 3), spline.getPointAtZeroToNIndex(1));
    EXPECT_EQ(Point2D(2, 4), spline.getPointAtZeroToNIndex(2));
    EXPECT_EQ(Point2D(5, 1), spline.getPointAtZeroToNIndex(3));

    // Check a couple points in between interpolation points
    Point2D p;

    // Point between the (1,1) and (3,3) interpolation points
    p = spline.getPointAtZeroToNIndex(0.5);
    EXPECT_GE(p.x(), 1);
    EXPECT_LE(p.x(), 3);
    EXPECT_GE(p.y(), 1);
    EXPECT_LE(p.y(), 3);

    // Point between the (2,4) and (5,1) interpolation points
    p = spline.getPointAtZeroToNIndex(2.5);
    EXPECT_GE(p.x(), 2);
    EXPECT_LE(p.x(), 5);
    EXPECT_GE(p.y(), 1);
    EXPECT_LE(p.y(), 4);
}
开发者ID:UBC-Snowbots,项目名称:IGVC-2017,代码行数:34,代码来源:Spline-test.cpp

示例2: DrawBox

void Viewer::DrawBox(const Point2D &x1, const Point2D &x2) {
  glBegin(GL_LINE_LOOP);
  glVertex2f(x1.x(), x1.y());
  glVertex2f(x1.x(), x2.y());
  glVertex2f(x2.x(), x2.y());
  glVertex2f(x2.x(), x1.y());
  glEnd();
}
开发者ID:haochihlin,项目名称:ICE-BA,代码行数:8,代码来源:Viewer.cpp

示例3: DrawQuad

void Viewer::DrawQuad(const Point2D &x1, const Point2D &x2) {
  glBegin(GL_QUADS);
  glVertex2f(x1.x(), x1.y());
  glVertex2f(x1.x(), x2.y());
  glVertex2f(x2.x(), x2.y());
  glVertex2f(x2.x(), x1.y());
  glEnd();
}
开发者ID:haochihlin,项目名称:ICE-BA,代码行数:8,代码来源:Viewer.cpp

示例4: DrawCross

void Viewer::DrawCross(const Point2D &x, const LA::Vector2f &size) {
  glBegin(GL_LINES);
  glVertex2f(x.x() - size.x(), x.y());
  glVertex2f(x.x() + size.x(), x.y());
  glVertex2f(x.x(), x.y() - size.y());
  glVertex2f(x.x(), x.y() + size.y());
  glEnd();
}
开发者ID:haochihlin,项目名称:ICE-BA,代码行数:8,代码来源:Viewer.cpp

示例5: c

  // ********************* SQUARE **********************
  Square::Square(Point2D origin, double length, double angle){
    this->isconvex=true;
    this->vertexes.reserve(4);
    vertexes.push_back(origin);
    double c(std::cos(angle));
    double s(std::sin(angle));
    vertexes.push_back(Point2D(origin.x()+length*c,
			       origin.y()+length*s));
    vertexes.push_back(Point2D(origin.x()+length*(c-s),
			       origin.y()+length*(c+s)));
    vertexes.push_back(Point2D(origin.x()-length*s,
			       origin.y()+length*c));
  }
开发者ID:idvr,项目名称:pacs,代码行数:14,代码来源:Polygon.cpp

示例6: drawPoint

void ViewportPainter::drawPoint(Point2D & point) {
    if(point.getTime() != "-1") {
      QString text("t = " + point.getTime());
      QRect rect(point.x()+TEXT_OFFSET_X, point.y()-TEXT_OFFSET_Y,10*text.length()+2*TEXT_MARGIN,15+2*TEXT_MARGIN);
      this->setBrush(QColor(255, 255, 255, 255));
      this->drawRect(rect);
      this->drawText(rect,Qt::AlignHCenter|Qt::AlignVCenter,text);
    }
    if(point.selected())
      this->setBrush(QColor(255, 0, 0, 255));
    else
      this->setBrush(QColor(255, 248, 133, 255));
    this->drawEllipse(point.x()-POINT_SIZE/2,point.y()-POINT_SIZE/2,POINT_SIZE,POINT_SIZE);
}
开发者ID:PaulGrandperrin,项目名称:demo-opengl-shootemup,代码行数:14,代码来源:viewportPainter.cpp

示例7: sqrt

double Point2D::distance(Point2D another) {

    double dx = x() - another.x();
    double dy = y() - another.y();

    return sqrt( dx*dx + dy*dy);

};
开发者ID:mauroalberti,项目名称:geoSurfDEM,代码行数:8,代码来源:spatial.cpp

示例8: x

Point2D Point2D::moveby(Point2D shift_pt) {

    double new_x = x() + shift_pt.x();
    double new_y = y() + shift_pt.y();

    return Point2D(new_x, new_y);

};
开发者ID:mauroalberti,项目名称:geoSurfDEM,代码行数:8,代码来源:spatial.cpp

示例9: add_point

bool Rectangle::add_point(const Point2D& p){
    if(is_point_within(p)){
        Point2D currPnt;
        bool newPnt = true;
        for(int x = 0; x <m_points_contained.size(); x++){
            currPnt = m_points_contained[x];
            if(currPnt.x() == p.x() && currPnt.y() == p.y())
                newPnt = false;
        }
        if(newPnt){
            m_points_contained.push_back(p);
            return true;
        }
        else return false;
    }
    else return false;
}
开发者ID:sirmarcis,项目名称:a9667backup,代码行数:17,代码来源:Rectangle.cpp

示例10: SetUp

void TerrainBlockTest::SetUp() {
    srtmFactory = std::make_unique<TempSRTMFileFactory>();
    
    srtmFactory->createFile(southWestPoint, [&](TempSRTMFileFactory::WriteValueCallback writeValue) {
        Point2D<int> southWestPixel(position.x() * 256, (position.y() + 1) * 256);
        Point2D<int> northEastPixel((position.x() + 1) * 256, position.y() * 256);
        Point2D<double> southWest = GeoPoint::fromPixel(southWestPixel, zoomLevel, 256);
        Point2D<double> northEast = GeoPoint::fromPixel(northEastPixel, zoomLevel, 256);
        
        short counter = 10;
        
        for (int y = (southWest.y() - southWestPoint.y()) * HeightMap::POINTS_IN_DEGREE;
             y <= ceil((northEast.y() - southWestPoint.y()) * HeightMap::POINTS_IN_DEGREE);
             y++) {
            for (int x = (southWest.x() - southWestPoint.x()) * HeightMap::POINTS_IN_DEGREE;
                 x <= ceil((northEast.x() - southWestPoint.x()) * HeightMap::POINTS_IN_DEGREE);
                 x++) {
                writeValue(y, x, counter += 10);
            }
        }
        
        writeValue(0, HeightMap::POINTS_IN_DEGREE, 0);
    });
    
    heightGrid = std::make_unique<HeightGrid>(srtmFactory->tmpDirectory(), [](int latitude, int longitude){});
    terrainBlock = std::make_unique<TerrainBlock>(Point3D<int>(position.x(), position.y(), zoomLevel), *heightGrid);
}
开发者ID:MKisilyov,项目名称:MountainKit,代码行数:27,代码来源:TerrainBlockTest.cpp

示例11: make_tuple

TEST_F(TerrainBlockTest, data) {
    Point2D<int> southWestPixel(position.x() * 256, (position.y() + 1) * 256);
    Point2D<int> northEastPixel((position.x() + 1) * 256, position.y() * 256);
    
    Point2D<double> southWest = GeoPoint::fromPixel(southWestPixel, zoomLevel, 256).toWebMercator();
    Point2D<double> northEast = GeoPoint::fromPixel(northEastPixel, zoomLevel, 256).toWebMercator();

    double referenceArea = (float(northEast.x()) - float(southWest.x())) * (float(northEast.y()) - float(southWest.y()));
    
    const std::vector<float>& vertexBuffer = terrainBlock->vertexBuffer();
    const auto& indexBuffer = TerrainBlock::indexBuffer();
    
    ASSERT_EQ(75, vertexBuffer.size());
    ASSERT_EQ(96, indexBuffer.size());
    
    auto readPolygon = [&](int startPosition) -> std::tuple<Point3D<float>, Point3D<float>, Point3D<float>> {
        return std::make_tuple(Point3D<float>(vertexBuffer[indexBuffer[startPosition] * 3],
                                              vertexBuffer[indexBuffer[startPosition] * 3 + 1],
                                              vertexBuffer[indexBuffer[startPosition] * 3 + 2]),
                               Point3D<float>(vertexBuffer[indexBuffer[startPosition + 1] * 3],
                                              vertexBuffer[indexBuffer[startPosition + 1] * 3 + 1],
                                              vertexBuffer[indexBuffer[startPosition + 1] * 3 + 2]),
                               Point3D<float>(vertexBuffer[indexBuffer[startPosition + 2] * 3],
                                              vertexBuffer[indexBuffer[startPosition + 2] * 3 + 1],
                                              vertexBuffer[indexBuffer[startPosition + 2] * 3 + 2]));
    };
    
    double terrainBlockArea = 0;
    
    std::unordered_set<long> heights;
    
    for (int i = 0; i < indexBuffer.size(); i += 3) {
        auto polygon = readPolygon(i);
        const Point3D<float>& p1 = std::get<0>(polygon);
        const Point3D<float>& p2 = std::get<1>(polygon);
        const Point3D<float>& p3 = std::get<2>(polygon);
        
        EXPECT_FALSE(p1 == p2);
        EXPECT_FALSE(p1 == p3);
        EXPECT_FALSE(p2 == p3);
        
        terrainBlockArea += triangleArea(p1, p2, p3);
        
        long h1 = lround(p1.z());
        long h2 = lround(p2.z());
        long h3 = lround(p3.z());
        EXPECT_NE(0, h1);
        EXPECT_NE(0, h2);
        EXPECT_NE(0, h3);
        heights.insert(h1);
        heights.insert(h2);
        heights.insert(h3);
    }
    
    EXPECT_FLOAT_EQ(referenceArea, terrainBlockArea);
    EXPECT_EQ(62 - 55 + 1, heights.size());
}
开发者ID:MKisilyov,项目名称:MountainKit,代码行数:57,代码来源:TerrainBlockTest.cpp

示例12:

void Point2D::rotate(double const& radiant, Point2D const& center, bool filled)
/* Bool Filled = true führt zu ausgeülltem Kreis. sollte viellcht in Klasse Kreis überladen werden?
 Oder eine adapter Klasse shape eingeführt werden.
 Diese benötigt diese Art der Drehung für die Darstellung. Derzeit.
 Ansonsten wird nur die Kontur gemalt. */
{ double x,y = 0;
    if ( !filled ) {
        x = -center.x()+x_;
        y = -center.y()+y_;
    } else {
        x = center.x()-x_;
        y = center.y()-y_;
    }
    Point2D r{x,y};
    r.rotate(radiant);
    x_ = r.x() + center.x();
    y_ = r.y() + center.y();
}
开发者ID:heinrich-foto,项目名称:fensterchen,代码行数:18,代码来源:point2D.cpp

示例13:

Point3D::Point3D(Point2D pt2d, double z, bool valid = true) {

    _valid = valid;

    _x = pt2d.x();
    _y = pt2d.y();
    _z = z;

};
开发者ID:mauroalberti,项目名称:geoSurfDEM,代码行数:9,代码来源:spatial.cpp

示例14: drawBezierCurve

void ViewportPainter::drawBezierCurve(BezierCurve & curve) {
    Point2D * beginPoint = curve.getBeginPoint();
    Point2D * endPoint = curve.getEndPoint();
    Point2D * controlPoint = curve.getControlPoint();
    
    // Plus tard dessin de la courbe :
    // this->drawArc(beginPoint->x(),beginPoint->y(),endPoint->x()-beginPoint->x(),endPoint->y()-beginPoint->y(),0*16,360*16);
      
    this->drawLine(beginPoint->x(),beginPoint->y(),endPoint->x(),endPoint->y());
    
    // Dessin du vecteur
    /*this->setPen(QColor(255, 120, 0, 255));
    this->drawPoint(*controlPoint);
    this->drawLine(beginPoint->x(),beginPoint->y(),controlPoint->x(),controlPoint->y());
    // Dessiner la fleche du vecteur
    //this->drawLine(controlPoint->x(),controlPoint->y());
    //this->drawLine(controlPoint->x(),controlPoint->y());
    this->setPen(QColor(0, 0, 0, 255));*/
}
开发者ID:PaulGrandperrin,项目名称:demo-opengl-shootemup,代码行数:19,代码来源:viewportPainter.cpp

示例15: draw

	void LaserLauncher::draw(void) const
	{
		using namespace ImageHandle;

		const auto count{get_count()};
		const auto angle{this->angle()};

		const Point2D P{d->d * Point2D(-sin(angle), cos(angle))};
		gp::DrawRotaGraphF(gp::level(11), pos().x(), pos().y(), 0.08, angle, shaft, true);
		gp::DrawRotaGraphF(gp::level(11), pos().x() - P.x(), pos().y() - P.y(), 0.08, angle, right_shell, true);
		gp::DrawRotaGraphF(gp::level(11), pos().x() + P.x(), pos().y() + P.y(), 0.08, angle, left_shell, true);
	}
开发者ID:yamikumo-DSD,项目名称:my_game_project_unified,代码行数:12,代码来源:laser_launcher.cpp


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