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


C++ point_type类代码示例

本文整理汇总了C++中point_type的典型用法代码示例。如果您正苦于以下问题:C++ point_type类的具体用法?C++ point_type怎么用?C++ point_type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: swap

void GerberImporter::linear_draw_circular_aperture(point_type startpoint, point_type endpoint,
                                    coordinate_type radius, unsigned int circle_points, ring_type& ring)
{
    const coordinate_type dx = endpoint.x() - startpoint.x();
    const coordinate_type dy = endpoint.y() - startpoint.y();
    double angle_step;
    double offset;
    
    if (circle_points % 2 == 0)
        ++circle_points;

    if (startpoint.x() > endpoint.x())
        swap(startpoint, endpoint);

    angle_step = 2 * bg::math::pi<double>() / circle_points;
    
    if (dx == 0)
        offset = bg::math::pi<double>();
    else
        offset = atan(dy / dx) + bg::math::pi<double>() / 2;
    
    for (unsigned int i = 0; i < circle_points / 2 + 1; i++)
        ring.push_back(point_type(cos(angle_step * i + offset) * radius + startpoint.x(),
                               sin(angle_step * i + offset) * radius + startpoint.y()));

    offset += bg::math::pi<double>();

    for (unsigned int i = 0; i < circle_points / 2 + 1; i++)
        ring.push_back(point_type(cos(angle_step * i + offset) * radius + endpoint.x(),
                               sin(angle_step * i + offset) * radius + endpoint.y()));
    
    bg::correct(ring);
}
开发者ID:corna,项目名称:pcb2gcode,代码行数:33,代码来源:gerberimporter.cpp

示例2: sin

void GerberImporter::draw_oval(point_type center, coordinate_type width, coordinate_type height,
                                coordinate_type hole_diameter, unsigned int circle_points, polygon_type& polygon)
{
    double angle_step;
    double offset;
    coordinate_type x;
    coordinate_type y;
    coordinate_type radius;
    
    if (circle_points % 2 == 0)
        ++circle_points;
    
    angle_step = -2 * bg::math::pi<double>() / circle_points;
    
    if (width < height)
    {
        radius = width / 2;
        offset = 0;
        x = 0;
        y = height / 2 - radius;
    }
    else
    {
        radius = height / 2;
        offset = -bg::math::pi<double>() / 2;
        x = width / 2 - radius;
        y = 0;
    }
    
    for (unsigned int i = 0; i < circle_points / 2 + 1; i++)
        polygon.outer().push_back(point_type(cos(angle_step * i + offset) * radius + center.x() - x,
                                                sin(angle_step * i + offset) * radius + center.y() - y));

    offset += bg::math::pi<double>();

    for (unsigned int i = 0; i < circle_points / 2 + 1; i++)
        polygon.outer().push_back(point_type(cos(angle_step * i + offset) * radius + center.x() + x,
                                                sin(angle_step * i + offset) * radius + center.y() + y));

    polygon.outer().push_back(polygon.outer().front());

    if (hole_diameter != 0)
    {
        polygon.inners().resize(1);
        draw_regular_polygon(center, hole_diameter, circle_points, 0, false, polygon.inners().front());
    }
}
开发者ID:corna,项目名称:pcb2gcode,代码行数:47,代码来源:gerberimporter.cpp

示例3: draw_regular_polygon

void GerberImporter::draw_regular_polygon(point_type center, coordinate_type diameter, unsigned int vertices,
                            coordinate_type offset, bool clockwise, ring_type& ring)
{
    double angle_step;
    
    if (clockwise)
        angle_step = -2 * bg::math::pi<double>() / vertices;
    else
        angle_step = 2 * bg::math::pi<double>() / vertices;

    offset *= bg::math::pi<double>() / 180.0;

    for (unsigned int i = 0; i < vertices; i++)
       ring.push_back(point_type(cos(angle_step * i + offset) * diameter / 2 + center.x(),
                        sin(angle_step * i + offset) * diameter / 2 + center.y()));

    ring.push_back(ring.front());
}
开发者ID:corna,项目名称:pcb2gcode,代码行数:18,代码来源:gerberimporter.cpp

示例4: ceil

void GerberImporter::circular_arc(point_type center, coordinate_type radius,
                    double angle1, double angle2, unsigned int circle_points,
                    linestring_type& linestring)
{
    const unsigned int steps = ceil((angle2 - angle1) / (2 * bg::math::pi<double>()) * circle_points);
    const double angle_step = (angle2 - angle1) / steps;
    
    for (unsigned int i = 0; i < steps; i++)
    {
        const double angle = angle1 + i * angle_step;

        linestring.push_back(point_type(cos(angle) * radius + center.x(),
                                        sin(angle) * radius + center.y()));
    }
    
    linestring.push_back(point_type(cos(angle2) * radius + center.x(),
                                    sin(angle2) * radius + center.y()));
}
开发者ID:corna,项目名称:pcb2gcode,代码行数:18,代码来源:gerberimporter.cpp

示例5: draw_rectangle

void GerberImporter::draw_rectangle(point_type center, coordinate_type width, coordinate_type height,
                                    coordinate_type hole_diameter, unsigned int circle_points, polygon_type& polygon)
{
    const coordinate_type x = center.x();
    const coordinate_type y = center.y();

    polygon.outer().push_back(point_type(x - width / 2, y - height / 2));
    polygon.outer().push_back(point_type(x - width / 2, y + height / 2));
    polygon.outer().push_back(point_type(x + width / 2, y + height / 2));
    polygon.outer().push_back(point_type(x + width / 2, y - height / 2));
    polygon.outer().push_back(polygon.outer().front());
    
    if (hole_diameter != 0)
    {
        polygon.inners().resize(1);
        draw_regular_polygon(center, hole_diameter, circle_points, 0, false, polygon.inners().front());
    }
}
开发者ID:corna,项目名称:pcb2gcode,代码行数:18,代码来源:gerberimporter.cpp

示例6: sliceTriangle

      void sliceTriangle(const point_type& A,
                         const point_type& B,
                         const point_type& C,
                         const vec_type& N,
                         SegmentStack& _segmentStack) const
      {
        using geometry::prim::Segment;
        typedef geometry::comp::Compound<Segment> SegmentPlane;
        
        SegmentStack::iterator _Ait = _segmentStack.get(A.z()),
                               _Bit = _segmentStack.get(B.z()),
                               _Cit = _segmentStack.get(C.z()),
                               it;

        Point2f _Aproj = A.project(geometry::base::Z);
        vec_type b = B - A;
        scalar_type _invBz = 1.0 / b.z();
        vec_type c = C - A;
        scalar_type _invCz = 1.0 / c.z();
        vec_type d = C - B;
        scalar_type _invDz = 1.0 / d.z();
        scalar_type _ratioR, _ratioS, _pos;
        Vec2f r,s;

        bool _passedB = false;

        for (it = _Ait ; it != _Cit && it != _segmentStack.end(); ++it)
        {
          SegmentPlane* _segmentPlane = &(it->second);
          if (it == _Bit) _passedB = true;

          if (!_passedB)
          {
            _pos = it->first - A.z();
            _ratioR = _pos * _invCz;
            _ratioS = _pos * _invBz;
            s(b.x()*_ratioS,b.y()*_ratioS);
          } else
          {
            _pos = it->first;
            _ratioR = (_pos - A.z()) * _invCz;
            _ratioS = (_pos - B.z()) * _invDz;
            s(b.x() + d.x()*_ratioS,b.y() + d.y()*_ratioS);
          }
          
          r(c.x()*_ratioR,c.y()*_ratioR);

          Point2f _p0 = _Aproj+r, _p1 = _Aproj+s;
          Vec2f _normal = _p1 - _p0;  // Normal of segment points
          if (_normal.sqrLength() == 0.0) continue;
          _normal(-_normal[1],_normal[0]);
          /// Swap point to assure that points are in proper order to be able to make lineSegments
          if (dot(Vec2f(N.x(),N.y()),_normal) > 0.0) std::swap(_p0,_p1);
          _segmentPlane->add(Segment(_p0,_p1));
        }
      }
开发者ID:aeickho,项目名称:Tomo,代码行数:56,代码来源:TriangleSlicer.hpp

示例7: atan2

void GerberImporter::draw_rectangle(point_type point1, point_type point2, coordinate_type height, polygon_type& polygon)
{
    const double angle = atan2(point2.y() - point1.y(), point2.x() - point1.x());
    const coordinate_type dx = height / 2 * sin(angle);
    const coordinate_type dy = height / 2 * cos(angle);

    polygon.outer().push_back(point_type(point1.x() + dx, point1.y() - dy));
    polygon.outer().push_back(point_type(point1.x() - dx, point1.y() + dy));
    polygon.outer().push_back(point_type(point2.x() - dx, point2.y() + dy));
    polygon.outer().push_back(point_type(point2.x() + dx, point2.y() - dy));
    polygon.outer().push_back(polygon.outer().front());
    
    bg::correct(polygon);
}
开发者ID:corna,项目名称:pcb2gcode,代码行数:14,代码来源:gerberimporter.cpp

示例8: update_object

void RemoteServerProxy::update_object(uint32_t object_id, double x, double y, char type, point_type points,
  bool alive) {
  if (alive) {
    if (renderers_.find(object_id) != renderers_.end()) {
      renderers_[object_id]->update_position(Vector(x, y));
    } else if (type == 'b') {
        renderers_[object_id] = new BulletRenderer(Vector(x, y), points.front().x());
    } else if (type == 'l') {
      renderers_[object_id] = new NewLifeRenderer(Vector(x, y), points.front().x());
    }
  } else if (object_id != object_id_) {
    if (renderers_.find(object_id) != renderers_.end()) {
      Renderer *render = renderers_[object_id];
      renderers_.erase(object_id);
      delete render;
    }
  } else {
    if (notify_dead_) {
      Logger::info("Perdio todas las vidas");
      notifier_("PERDISTE TODAS LAS VIDAS");
      notify_dead_ = false;
    }
  }
}
开发者ID:tinchou,项目名称:bluesjackrabbit,代码行数:24,代码来源:RemoteServerProxy.cpp

示例9: set

 static inline void set(point_type& p, CoordinateType const& value)
 {
     p.y(value);
 }
开发者ID:Niko-r,项目名称:geofeatures,代码行数:4,代码来源:point.hpp

示例10: get

 static inline CoordinateType get(point_type const& p)
 {
     return p.y();
 }
开发者ID:Niko-r,项目名称:geofeatures,代码行数:4,代码来源:point.hpp

示例11: operator

 bool operator()(const point_type& a, const point_type& b) const {
   return std::tie(a.x(), a.y()) < std::tie(b.x(), b.y());
 }
开发者ID:kmjonsson,项目名称:pcb2gcode,代码行数:3,代码来源:segmentize_tests.cpp

示例12: point_difference_type

      point_difference_type(const point_type& aSrc, 
			    const point_type& aDst) :
                            M(aSrc.get_matrix() - aDst.get_matrix()) { };
开发者ID:ahmadyan,项目名称:ReaK,代码行数:3,代码来源:covar_topology.hpp

示例13: move_position_toward

 /**
  * Computes the covariance matrix which is the linear interpolation between two matrices, by a fraction.
  * \param a The first covariance matrix.
  * \param fraction The scalar fraction at which the evaluate the linear interpolation.
  * \param b The second covariance matrix.
  * \return The interpolated covariance matrix.
  */
 point_type move_position_toward(const point_type& a, double fraction, const point_type& b) const {
   return point_type(matrix_type(value_type(1.0 - fraction) * a.get_matrix() + value_type(fraction) * b.get_matrix()));
 };
开发者ID:ahmadyan,项目名称:ReaK,代码行数:10,代码来源:covar_topology.hpp

示例14: adjust

 /**
  * Adds a given covariance matrix difference to a given covariance matrix.
  * \param a A covariance matrix.
  * \param delta A covariance matrix difference to add to a.
  * \return The adjusted covariance matrix.
  */
 point_type adjust(const point_type& a, const point_difference_type& delta) const {
   return point_type(matrix_type( a.get_matrix() + delta.M ));
 };
开发者ID:ahmadyan,项目名称:ReaK,代码行数:9,代码来源:covar_topology.hpp

示例15: copy_ring

shared_ptr<multi_polygon_type> Voronoi::build_voronoi(const multi_polygon_type& input,
                                coordinate_type bounding_box_offset, coordinate_type max_dist)
{
    auto output = make_shared<multi_polygon_type>();
    voronoi_diagram_type voronoi_diagram;
    voronoi_builder_type voronoi_builder;
    vector<segment_type_p> segments;
    list<const cell_type *> visited_cells;
    size_t segments_num = 0;
    ring_type bounding_box_ring;

    bg::assign(bounding_box_ring, bg::return_buffer<box_type>(
                                bg::return_envelope<box_type>(input), bounding_box_offset));

    for (const polygon_type& polygon : input)
    {
        segments_num += polygon.outer().size() - 1;
        
        for (const ring_type& ring : polygon.inners())
        {
            segments_num += ring.size() - 1;
        }
    }
    
    segments_num += bounding_box_ring.size() - 1;
    
    segments.reserve(segments_num);
    
    for (const polygon_type& polygon : input)
    {
        copy_ring(polygon.outer(), segments);

        for (const ring_type& ring : polygon.inners())
        {
            copy_ring(ring, segments);
        }
    }
    
    copy_ring(bounding_box_ring, segments);

    output->resize(input.size());
    for (size_t i = 0; i < input.size(); i++)
        (*output)[i].inners().resize(input.at(i).inners().size());

    boost::polygon::insert(segments.begin(), segments.end(), &voronoi_builder);
    voronoi_builder.construct(&voronoi_diagram);

    for (const cell_type& cell : voronoi_diagram.cells())
    {
        if (!cell.is_degenerate())
        {
            const edge_type *edge = cell.incident_edge();
            const cell_type *last_cell = NULL;
            const auto found_cell = std::find(visited_cells.begin(), visited_cells.end(), &cell);

            bool backwards = false;

            if (found_cell == visited_cells.end())
            {
                pair<const polygon_type *, ring_type *> related_geometries = find_ring(input, cell, *output);
                
                if (related_geometries.first && related_geometries.second)
                {
                    const polygon_type& polygon = *(related_geometries.first);
                    ring_type& ring = *(related_geometries.second);

                    do {
                        if (edge->is_primary())
                        {
                            if (edge->is_finite())
                            {
                                const point_type startpoint (edge->vertex0()->x(), edge->vertex0()->y());
                                const point_type endpoint (edge->vertex1()->x(), edge->vertex1()->y());
                                auto append_remove_extra = [&] (const point_type& point)
                                {
                                    /* 
                                     * This works, but it seems more a workaround than a proper solution.
                                     * Why are these segments here in the first place? FIXME
                                     */
                                    if (ring.size() >= 2 && bg::equals(point, *(ring.end() - 2)))
                                        ring.pop_back();
                                    else 
                                        ring.push_back(point);
                                };

                                if (bg::covered_by(startpoint, polygon) && bg::covered_by(endpoint, polygon))
                                {
                                    ring.clear();
                                    break;
                                }

                                if (ring.empty() || startpoint.x() != ring.back().x() || startpoint.y() != ring.back().y())
                                    append_remove_extra(startpoint);

                                if (edge->is_linear())
                                    append_remove_extra(endpoint);
                                else
                                {
                                    vector<point_type_fp_p> sampled_edge;

//.........这里部分代码省略.........
开发者ID:chrysn-pull-requests,项目名称:pcb2gcode,代码行数:101,代码来源:voronoi.cpp


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