本文整理汇总了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());
}
示例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());
}
示例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());
}
示例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());
}
示例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;
}