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


C++ PointVector::clear方法代码示例

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


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

示例1: Resample

    void Resample(PointVector& points, size_t n)
    {
        double I = PathLength(points) / (n - 1); // interval length
        double D = 0.0;
        PointVector newpoints;
        newpoints.push_back(points[0]);

        for (size_t i = 1; i < points.size(); ++i)
        {
            double d = Distance(points[i - 1], points[i]);
            if ((D + d) >= I)
            {
                double qx = points[i - 1]->X + ((I - D) / d) * (points[i]->X - points[i - 1]->X);
                double qy = points[i - 1]->Y + ((I - D) / d) * (points[i]->Y - points[i - 1]->Y);
                PointPtr q(new Point(qx, qy));
                newpoints.push_back(q);
                points.insert(points.begin()+i,q);
                D = 0.0;
            }
            else D += d;
        }
        // somtimes we fall a rounding-error short of adding the last point, so add it if so
        if (newpoints.size() == n - 1)
        {
            newpoints.push_back(points[points.size() - 1]);
        }

        points.clear();
        points.insert(points.begin(), newpoints.begin(), newpoints.end());
    }
开发者ID:rcfox,项目名称:NDS-1-Dollar-Gesture-Recognition,代码行数:30,代码来源:dollar.cpp

示例2: ScaleToSquare

 void ScaleToSquare(PointVector& points, double size)
 {
     RectanglePtr B = BoundingBox(points);
     PointVector newpoints;
     for (size_t i = 0; i < points.size(); ++i)
     {
         double qx = points[i]->X * (size / B->Width);
         double qy = points[i]->Y * (size / B->Height);
         newpoints.push_back(PointPtr(new Point(qx, qy)));
     }
     points.clear();
     points.insert(points.begin(), newpoints.begin(), newpoints.end());
 }
开发者ID:rcfox,项目名称:NDS-1-Dollar-Gesture-Recognition,代码行数:13,代码来源:dollar.cpp

示例3: TranslateToOrigin

 void TranslateToOrigin(PointVector& points)
 {
     PointPtr c = Centroid(points);
     PointVector newpoints;
     for (size_t i = 0; i < points.size(); ++i)
     {
         double qx = points[i]->X - c->X;
         double qy = points[i]->Y - c->Y;
         newpoints.push_back(PointPtr(new Point(qx, qy)));
     }
     points.clear();
     points.insert(points.begin(), newpoints.begin(), newpoints.end());
 }
开发者ID:rcfox,项目名称:NDS-1-Dollar-Gesture-Recognition,代码行数:13,代码来源:dollar.cpp

示例4: RotateBy

    void RotateBy(PointVector& points, double theta)
    {
        PointPtr c = Centroid(points);
        double cosine = cos(theta);
        double sine = sin(theta);

        PointVector newpoints;
        for (size_t i = 0; i < points.size(); ++i)
        {
            double qx = (points[i]->X - c->X) * cosine - (points[i]->Y - c->Y) * sine + c->X;
            double qy = (points[i]->X - c->X) * sine + (points[i]->Y - c->Y) * cosine + c->Y;
            newpoints.push_back(PointPtr(new Point(qx, qy)));
        }

        points.clear();
        points.insert(points.begin(), newpoints.begin(), newpoints.end());
    }
开发者ID:rcfox,项目名称:NDS-1-Dollar-Gesture-Recognition,代码行数:17,代码来源:dollar.cpp

示例5: TP

void auxdata::DrcPoly::motionDraw(const layprop::DrawProperties&, CtmQueue& transtack,
                                  SGBitSet* plst) const
{
    CTM trans = transtack.front();
    PointVector* ptlist = DEBUG_NEW PointVector;
    ptlist->reserve(_psize);
    for (unsigned i = 0; i < _psize; i++)
    {
        ptlist->push_back( TP(_pdata[2*i], _pdata[2*i+1]) * trans);
    }
    glBegin(GL_LINE_LOOP);
    for (unsigned i = 0; i < _psize; i++)
    {
        glVertex2i((*ptlist)[i].x(), (*ptlist)[i].y());
    }
    glEnd();
    ptlist->clear();
    delete ptlist;
}
开发者ID:etihwnad,项目名称:toped,代码行数:19,代码来源:calbr_reader.cpp


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