• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ VP类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: name

bool CParamManager::SetParam(VP& vp, char* pa)
{
	if ( pa == NULL ) return false;
	
	string name(pa);
	string value;
	
	string::size_type pos = name.find(':');
	if ( pos == string::npos ) return false;
	value = name.substr( pos+1, name.length()-pos );
	name = name.substr( 0, pos );
	
	VP_IT it = vp.find(name);
	if ( it == vp.end() ) return false;
	
	_CParam* p = (*it).second;
	switch ( p->type )
	{
		case PT_INT:
			*((int*)p->value) = CCStringMake(value.c_str())->intValue();
			break;
		case PT_FLOAT:
			*((float*)p->value) = CCStringMake(value.c_str())->floatValue();
			break;
		default:
			return false;
	}
	
	return true;
}
开发者ID:jobine,项目名称:FlightShoot,代码行数:30,代码来源:CParamManager.cpp


示例2: solve

    VP solve(vector<Line> line) {
        sort(line.begin(), line.end(), cmp());
        int n = unique(line.begin(), line.end(), kequal) - line.begin();
        assert(n > 2);

        int head = 0, tail = 1;
        que[0] = line[0]; que[1] = line[1];
        VP ret;
        for (int i = 2; i < n; i++) {
            if (fabs((que[tail].e - que[tail].s).det(que[tail - 1].e - que[tail - 1].s)) < eps ||
                fabs((que[head].e - que[head].s).det(que[head + 1].e - que[head + 1].s)) < eps) {
                return ret;
            }
            while (head < tail && ((isLL(que[tail], que[tail - 1])[0] - line[i].s)
                .det(line[i].e - line[i].s)) > eps) tail--;
            while (head < tail && ((isLL(que[head], que[head + 1])[0] - line[i].s)
                .det(line[i].e - line[i].s)) > eps) head++;
            que[++tail] = line[i];
        }
        while (head < tail && ((isLL(que[tail], que[tail - 1])[0] - que[head].s)
            .det(que[head].e - que[head].s)) > eps) tail--;
        while (head < tail && ((isLL(que[head], que[head + 1])[0] - que[tail].s)
            .det(que[tail].e - que[tail].s)) > eps) head++;

        if (tail <= head + 1)
            return ret;
        for (int i = head; i < tail; i++) {
            ret.push_back(isLL(que[i], que[i + 1])[0]);
        }
        if (head < tail + 1)
            ret.push_back(isLL(que[head], que[tail])[0]);
        return ret;
    }
开发者ID:Milrivel,项目名称:HelloWorld,代码行数:33,代码来源:Geometry-2D.cpp


示例3: test_container_with

 void test_container_with (VP &v1) const {
     // Container type tests in addition to expression types
     // Insert and erase
     v1.insert_element (0,0, 55);
     v1.erase_element (1,1);
     v1.clear ();
 }
开发者ID:BoostGSoC15,项目名称:ublas,代码行数:7,代码来源:test13.cpp


示例4: isLL

VP isLL(CP p1, CP p2, CP q1, CP q2){
    //二直线交点,无则返回空vector
    //返回空时有共线与相离的区别,用(p2 - p1).det(q1 - p1) == 0判断
    VP ret;
    T d = (q2 - q1).det(p2 - p1);
    if (fabs(d) < eps) return ret;
    ret.push_back(p1 + (p2 - p1) * ((q2 - q1).det(q1 - p1) / d));
    return ret;
}
开发者ID:Milrivel,项目名称:HelloWorld,代码行数:9,代码来源:Geometry-2D.cpp


示例5: ConvexCut

VP ConvexCut(const VP &ps, L l) {
  VP Q;
  for (int i = 0; i < (int)ps.size(); i++) {
    P A = ps[i], B = ps[(i+1)%ps.size()];
    if (ccw(l.a, l.b, A) != -1) Q.push_back(A);
    if (ccw(l.a, l.b, A) * ccw(l.a, l.b, B) < 0)
      Q.push_back(is_ll((L){A, B}, l));
  }
  return Q;
}
开发者ID:primenumber,项目名称:ProconLib,代码行数:10,代码来源:Convex.cpp


示例6: ConvexHull

VP ConvexHull(VP ps) {
  int n = ps.size();
  int k = 0;
  sort(ps.begin(), ps.end());
  VP ch(2 * n);
  for (int i = 0; i < n; ch[k++] = ps[i++])
    while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
  for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--])
    while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
  ch.resize(k - 1);
  return ch;
}
开发者ID:primenumber,项目名称:ProconLib,代码行数:12,代码来源:Convex.cpp


示例7: max_distance

ld max_distance(const VP &ps) {
  assert (ps.size() > 1);
  VP g = ConvexHull(ps);
  int n = g.size(), a = 0, b = 1;
  ld res = abs(g[0] - g[1]);
  while (a < n) {
    P p1 = g[a%n], p2 = g[(a+1)%n];
    P q1 = g[b%n], q2 = g[(b+1)%n];
    if (arg((p2 - p1) / (q1 - q2)) > 0) ++b; else ++a;
    res = max(res, abs(p1 - q1));
  }
  return res;
}
开发者ID:primenumber,项目名称:ProconLib,代码行数:13,代码来源:Convex.cpp


示例8: split_route

void split_route(vector<Segment> &vs,VR &nodes,int idx, int n1, int n2){
   ParamEdge e=vs[idx].edge;
   debugline(e.from(),e.to(),255,0,0,true);
   double minp=DBL_MAX;
   int minidx=-1;
   for (int j=0,n=nodes.size();j<n;j++){
      if (j==n1 || j==n2) continue;
      if (e.cross(nodes[j])){
	 if (nodes[j].contains(e.from())) continue;
	 if (nodes[j].contains(e.to())) continue;
         double p=e.cross_param_smallest(nodes[j]);
         if (p<minp){
            minp=p;
            minidx=j;
         }
      }
   }
   if (minidx<0) return ;
   Point dc=e.dist_vec(nodes[minidx].center());
   if (dc.is_null()){
      dc=to_left(e.unit(),PI/2); // minidxust choose a side 
   }
   VP pts;
   Point r=e.dist_vec(nodes[minidx].TL());
   if (scalar(r,dc)<0) pts.push_back(nodes[minidx].TL());
   r=e.dist_vec(nodes[minidx].TR());
   if (scalar(r,dc)<0) pts.push_back(nodes[minidx].TR());
   r=e.dist_vec(nodes[minidx].BL());
   if (scalar(r,dc)<0) pts.push_back(nodes[minidx].BL());
   r=e.dist_vec(nodes[minidx].BR());
   if (scalar(r,dc)<0) pts.push_back(nodes[minidx].BR());
   if (pts.size()==0) {
      printf("Ups, no points on smaller side of edge/node cut area");
      return;
   }
   if (pts.size()>2 ) throw "expected 1 or 2 points";
   vector<Segment> vsnew;
   int idxlast=idx+1;
   if (pts.size()==1){
      vsnew.push_back(Segment(ParamEdge(e.from(),pts[0]),vs[idx].first,false));
      vsnew.push_back(Segment(ParamEdge(pts[0],e.to()),false,vs[idx].last));
   } else if (pts.size()==2) {
      if (norm(pts[0]-e.from())>norm(pts[1]-e.from())){ // do nearest point first
	swap(pts[0],pts[1]);
      }
      vsnew.push_back(Segment(ParamEdge(e.from(),pts[0]),vs[idx].first,false));
      vsnew.push_back(Segment(ParamEdge(pts[0],pts[1]),false,false));
      vsnew.push_back(Segment(ParamEdge(pts[1],e.to()),false,vs[idx].last));
      idxlast++;
   }
   vs.erase(vs.begin()+idx);
   vs.insert(vs.begin()+idx,vsnew.begin(),vsnew.end());
   split_route(vs,nodes,idxlast,minidx,n2);
   split_route(vs,nodes,idx,n1,minidx); // new overlaps could be introduced after makeing a kink into the line
}
开发者ID:fugufisch,项目名称:biographer,代码行数:55,代码来源:edgerouting.cpp


示例9: cut_convex

void cut_convex(VP& a, Point p1, Point p2) {
    VP b;
    repn(i, sz(a)) {
        Point a1 = a[i], a2 = a[(i + 1) % a.size()];
        double m1 = mult(p1, p2, a1);
        double m2 = mult(p1, p2, a2);
        if(sgn(m1) * sgn(m2) < 0) {
            Point tmp;
            tmp.x = (a1.x * m2 - a2.x * m1) / (m2 - m1);
            tmp.y = (a1.y * m2 - a2.y * m1) / (m2 - m1);
            b.push_back(tmp);
        }
        if(sgn(m2) >= 0) b.push_back(a2);
    }
开发者ID:caiwaifung,项目名称:algo,代码行数:14,代码来源:PolygonRotation.cpp


示例10: isCL

VP isCL(CP c, double r, CP p1, CP p2) {
    //返回值按到p1的距离从小到大排列
    double x = (p1 - c).dot(p2 - p1);
    double y = (p2 - p1).abs2();
    double d = x * x - y * ((p1 - c).abs2() - r * r);
    if (d < -eps) return VP(0);
    if (d < 0) d = 0;
    Point q1 = p1 - (p2 - p1) * (x / y);
    Point q2 = (p2 - p1) * (sqrt(d) / y);
    VP ret;
    ret.push_back(q1 - q2);
    ret.push_back(q1 + q2);
    return ret;
}
开发者ID:Milrivel,项目名称:HelloWorld,代码行数:14,代码来源:Geometry-2D.cpp


示例11: calcPos

int calcPos(VI &data,VVI &g,int node)
{
    int ret=-1;

    VI wc(n , 0);
    VI pos(n , -1);

    int curNode = data[n-1];

    for(int i = sz(data)-2 ; i>=0 ; i--)
    {
        if(g[curNode][data[i]])
        {
            wc[curNode]++;
        }
        else
        {
            wc[data[i]]++;
            curNode = data[i];
        }
    }

    for(int i = 0 ; i<n ; i++)
        cout<<i <<" wc "<<wc[i]<<endl;

    pos[curNode] = 1;

    VP slist;
    int idx = 2;
    for(int i = 0 ; i<n ; i++)
    {
        if(i==curNode) continue;
        slist.push_back({ wc[i] , i });
    }

    sort(slist.begin() , slist.end());

    for(int i = sz(slist)-1 ; i>=0 ; i--)
    {
        if(i==(sz(slist)-1) || (slist[i].x!=slist[i+1].x))
            pos[slist[i].y] = idx++;
        else pos[slist[i].y] = pos[slist[i+1].y];
    }
    for(int i = 0 ; i<n ; i++)
    {
        cout<<i<<" pos "<<pos[i]<<endl;
    }
    return pos[node];
}
开发者ID:maruf0011,项目名称:Programming,代码行数:49,代码来源:D.cpp


示例12: areaCP

double areaCP(VP ps, Point center, double r) {
    int n = ps.size();
    double ans = 0;
    for (int i = 0; i < n; i++) {
        ans += areaCT(ps[i], ps[(i + 1) % n], center, r);
    }
    return ans;
}
开发者ID:Milrivel,项目名称:HelloWorld,代码行数:8,代码来源:Geometry-2D.cpp


示例13: areaCT

double areaCT(Point p1, Point p2, double r) {
    VP qs = isCL(0, r, p1, p2);
    if (qs.size() == 0) return r * r * rad(p1, p2) / 2;
    bool b1 = p1.abs() > r + eps, b2 = p2.abs() > r + eps;
    if (b1 && b2) {
        if ((p1 - qs[0]).dot(p2 - qs[0]) < eps &&
            (p1 - qs[1]).dot(p2 - qs[1]) < eps) {
            return (r * r * (rad(p1, p2) - rad(qs[0], qs[1])) +
                qs[0].det(qs[1])) / 2;
        } else {
            return r * r * rad(p1, p2) / 2;
        }
    } else if (b1) {
        return (r * r * rad(p1, qs[0]) + qs[0].det(p2)) / 2;
    } else if (b2) {
        return (r * r * rad(qs[1], p2) + p1.det(qs[1])) / 2;
    } else {
        return p1.det(p2) / 2;
    }
}
开发者ID:Milrivel,项目名称:HelloWorld,代码行数:20,代码来源:Geometry-2D.cpp


示例14: CreateFromPoints

void Polygon::CreateFromPoints(const VP& SomePoints)
{
    m_pPosition = Sum(SomePoints)/SomePoints.size();

    m_vPoints = ConvexHull(SomePoints);

    for (auto& m_vPoint : m_vPoints)
    {
        m_vPoint -= m_pPosition;
    }
}
开发者ID:mraggi,项目名称:Graph,代码行数:11,代码来源:Polygon.cpp


示例15: convexCut

VP convexCut(VP ps, CP p1, CP p2) {
    //返回凸多边形被有向直线p1p2切割后左半部分, 可改为在线半平面交
    int n = ps.size();
    VP ret(0);
    for (int i = 0; i < n; i++) {
        int d1 = sgn((p2 - p1).det(ps[i] - p1));
        int d2 = sgn((p2 - p1).det(ps[(i + 1) % n] - p1));
        if (d1 >= 0) ret.push_back(ps[i]);
        if (d1 * d2 < 0) ret.push_back(isLL(p1, p2, ps[i], ps[(i + 1) % n])[0]);
    }
    return ret;
}
开发者ID:Milrivel,项目名称:HelloWorld,代码行数:12,代码来源:Geometry-2D.cpp


示例16: main

int main()
{
    int tcase,cas=1;
    cin>>tcase;

    while(tcase--)
    {
        cin>>n;

        VVI g(n , VI(n , 0));

        for(auto &x: g)
            for(auto &y: x)
                cin>> y;

        VP slist;

        for(int i = 0 ; i<n  ; i++)
        {
            int cnt = 0;
            for(int j =0 ; j<n ; j++)
                cnt+= g[i][j];

            slist.push_back({cnt , i});
        }

        sort(slist.begin() , slist.end());

        VP sol;

        for(int i = 0 ; i<n ; i++)
        {
            int mx = posMax(g , slist , i);
            int mn = posMin(g , slist , i);

            cout<<i<<" "<<mx<<" "<<mn<<endl;
        }
    }
    return 0;
}
开发者ID:maruf0011,项目名称:Programming,代码行数:40,代码来源:D.cpp


示例17: contains

int contains(VP ps, CP q) {
    int n = ps.size();
    int res = -1;
    for (int i = 0; i < n; i++) {
        Point a = ps[i] - q, b = ps[(i + 1) % n] - q;
        if (a.y > b.y) {
            Point t = a; a = b; b = t;
        }
        if (a.y < eps && b.y > eps && a.det(b) > eps) {
            res = -res;
        }
        if (abs(a.det(b)) < eps && a.dot(b) < eps) {
            return 0;
        }
    }
    return res;
}
开发者ID:Milrivel,项目名称:HelloWorld,代码行数:17,代码来源:Geometry-2D.cpp


示例18: convexDiameter

double convexDiameter(VP ps) {
    int n = ps.size();
    int is = 0, js = 0;
    for (int i = 1; i < n; i++) {
        if (ps[i].x > ps[is].x) is = i;
        if (ps[i].x < ps[js].x) js = i;
    }
    double maxd = (ps[is] - ps[js]).abs();
    int i = is, j = js;
    do {
        if ((ps[(i + 1) % n] - ps[i]).det(ps[(j + 1) % n] - ps[j]) >= 0) {
            j = (j + 1) % n;
        } else {
            i = (i + 1) % n;
        }
        maxd = max(maxd, (ps[i] - ps[j]).abs());
    } while (i != is || j != js);
    return maxd;
}
开发者ID:Milrivel,项目名称:HelloWorld,代码行数:19,代码来源:Geometry-2D.cpp


示例19: cal_convex

VP cal_convex(VP a) {
    VP r;
    sort(all(a));
    for(const auto& p: a) {
        while(sz(r)>1 && cross(r[sz(r)-2], r[sz(r)-1], p)<=0) r.pop_back();
        r.pb(p);
    }
    int K=sz(r);
    reverse(all(a));
    for(const auto& p: a) {
        while(sz(r)>K && cross(r[sz(r)-2], r[sz(r)-1], p)<=0) r.pop_back();
        r.pb(p);
    }
    r.pop_back();
    return r;
}
开发者ID:caiwaifung,项目名称:algo,代码行数:16,代码来源:e.cpp


示例20: assert

Polygon::Polygon(const VP& SomePoints, bool alreadyconvex)
{
    assert(!SomePoints.empty());

    // 	cout << "Polygon::cctor" << endl;
    if (alreadyconvex)
    {
        m_vPoints = SomePoints;
    }
    else
    {
        m_vPoints = ConvexHull(SomePoints);
    }
    // 	cout << "getting center of mass" << endl;

    m_pPosition = Sum(m_vPoints)/m_vPoints.size();

    // 	cout << "substracting" << endl;
    for (auto& m_vPoint : m_vPoints)
    {
        m_vPoint -= m_pPosition;
    }
    // 	cout << "done" << endl;
}
开发者ID:mraggi,项目名称:Graph,代码行数:24,代码来源:Polygon.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ VP56Context类代码示例发布时间:2022-05-31
下一篇:
C++ VO_Shape类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap