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


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

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


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

示例1: test_point_at_fraction

int test_point_at_fraction()
{
  Trajectory2D test_trajectory;

  TrajectoryPoint2D points[3];
  points[0][0] = 0;
  points[0][1] = 0;
  points[0].set_object_id("test");
  points[0].set_timestamp(tracktable::time_from_string("2010-01-01 00:00:00"));

  points[1][0] = 4;
  points[1][1] = 1;
  points[1].set_object_id("test");
  points[1].set_timestamp(tracktable::time_from_string("2010-01-01 02:00:00"));

  points[2][0] = 8;
  points[2][1] = 0;
  points[2].set_object_id("test");
  points[2].set_timestamp(tracktable::time_from_string("2010-01-01 04:00:00"));

  test_trajectory.push_back(points[0]);
  test_trajectory.push_back(points[1]);
  test_trajectory.push_back(points[2]);

  int error_count = 0;
  Point2D halfway = tracktable::point_at_fraction(test_trajectory, 0.5);
  if (halfway != points[1])
    {
    std::cout << "ERROR: Expected halfway point to return exactly the second point.\n";
    std::cout << "Expected point: " << points[1].to_string() << "\n";
    std::cout << "Got point:      " << halfway.to_string() << "\n";
    ++error_count;
    }

  Point2D one_quarter = tracktable::point_at_fraction(test_trajectory, 0.25);
  if (!(tracktable::almost_equal(one_quarter[0], 2.0) &&
        tracktable::almost_equal(one_quarter[1], 0.5)))
    {
    std::cout << "ERROR: Expected one-quarter point to be at (2, 0.5).  Instead it is at ("
              << one_quarter[0] << ", " << one_quarter[1]
              << ").\n";
    ++error_count;
    }

  return error_count;
}
开发者ID:atwilso,项目名称:tracktable,代码行数:46,代码来源:test_point_at_fraction.cpp


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