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


C++ Convex类代码示例

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


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

示例1: detect

bool GJKCollisionDetector::detect(const Convex& convex1, const Transform2& transform1, const Convex& convex2,
                                  const Transform2& transform2, Penetration& penetration)
{
    if (convex1.getType() == ConvexType::CIRCLE && convex2.getType() == ConvexType::CIRCLE)
    {
        return CircleDetector::detect(
                reinterpret_cast<const Circle&>(convex1),
                transform1,
                reinterpret_cast<const Circle&>(convex2),
                transform2,
                penetration);
    }

    vector<fvec2> simplex;
    MinkowskiSum minkowskiSum(convex1, transform1, convex2, transform2);
    fvec2 direction = calcInitialDirection(convex1, transform1, convex2, transform2);

    if (detect(minkowskiSum, simplex, direction))
    {
        penetrationSolver->findPenetration(simplex, minkowskiSum, penetration);
        return true;
    }

    return false;
}
开发者ID:Discordia,项目名称:gjk-epa,代码行数:25,代码来源:GJKCollisionDetector.cpp

示例2: area

double area(Convex a) {
    double sum = 0;
    a.push_back(a[0]);
    for (int i = 0; i < a.size() - 1; i++) {
        sum += cross(a[i], a[i+1]);
    }
    return sum / 2.0;
}
开发者ID:wujysh,项目名称:2015_ACM_Summer_Training,代码行数:8,代码来源:ZOJ_3154_Mixed_Juice.cpp

示例3: convexIntersection

Convex convexIntersection(Convex v1, Convex v2) {
    vector<Halfplane> h;
    for (int i = 0; i < v1.size(); i++) {
        h.push_back(Halfplane(v1[i], v1[(i+1) % v1.size()]));
    }
    for (int i = 0; i < v2.size(); i++) {
        h.push_back(Halfplane(v2[i], v2[(i+1) % v2.size()]));
    }
    return halfplaneIntersection(h);
}
开发者ID:wujysh,项目名称:2015_ACM_Summer_Training,代码行数:10,代码来源:ZOJ_3154_Mixed_Juice.cpp

示例4: calcInitialDirection

fvec2 GJKCollisionDetector::calcInitialDirection(
        const Convex& convex1,
        const Transform2& transform1,
        const Convex& convex2,
        const Transform2& transform2)
{
    fvec2 c1 = transform1.getTransformed(convex1.getCenter());
    fvec2 c2 = transform2.getTransformed(convex2.getCenter());

    return c2 - c1;
}
开发者ID:Discordia,项目名称:gjk-epa,代码行数:11,代码来源:GJKCollisionDetector.cpp

示例5: getWorkingList

void Convex::renderWorkingList()
{
   //bool rendered = false;

   CollisionWorkingList& rList = getWorkingList();
   CollisionWorkingList* pList = rList.wLink.mNext;
   while (pList != &rList) {
      Convex* pConvex = pList->mConvex;
      pConvex->render();
      //rendered = true;
      pList = pList->wLink.mNext;
   }

   //Log::warnf( "convex rendered - %s", rendered ? "YES" : "NO" );
}
开发者ID:jamesu,项目名称:libDTShape,代码行数:15,代码来源:convex.cpp

示例6: matMulMat

void computeBV<AABB>(const Convex& s, AABB& bv)
{
  Vec3f R[3];
  matMulMat(s.getRotation(), s.getLocalRotation(), R);
  Vec3f T = matMulVec(s.getRotation(), s.getLocalTranslation()) + s.getTranslation();

  AABB bv_;
  for(int i = 0; i < s.num_points; ++i)
  {
    Vec3f new_p = matMulVec(R, s.points[i]) + T;
    bv_ += new_p;
  }

  bv = bv_;
}
开发者ID:Gitu1997,项目名称:Gazebo,代码行数:15,代码来源:geometric_shapes_utility.cpp

示例7: main

int main()
{
    Convex      CX;
    PointList   AllPoints, HullPoints;
    FacetList   HullFacets;

    CX.InputPointList(&AllPoints);
    
    CX.Calculation (&HullFacets, &AllPoints );
    CX.FacetToPoints(&HullFacets, &HullPoints);

    CX.OutputPointList (&HullPoints);

    return 0;

}
开发者ID:dymo1991,项目名称:convhull,代码行数:16,代码来源:convex.cpp

示例8: find_prim

bool find_prim(const Complex& a, const Convex& b, 
	       const Transform& a2w, const Transform& b2w,
	       Vector& v, ShapePtr& p) {
  Transform b2a;
  b2a.multInverseLeft(a2w, b2w);
  BBox bb = b.bbox(b2a);
  return find_prim(a.root, b, bb, b2a, v, p);
}
开发者ID:UWEcoCAR,项目名称:car-simulator,代码行数:8,代码来源:Complex.cpp

示例9: intersect

bool intersect(const Complex& a, const Convex& b, 
	       const Transform& a2w, const Transform& b2w,
	       Vector& v) {
  Transform b2a;
  b2a.multInverseLeft(a2w, b2w);
  BBox bb = b.bbox(b2a);
  return intersect(a.root, b, bb, b2a, v);
}
开发者ID:UWEcoCAR,项目名称:car-simulator,代码行数:8,代码来源:Complex.cpp

示例10: common_point

bool common_point(const Complex& a, const Convex& b, 
		  const Transform& a2w, const Transform& b2w,
		  Vector& v, Point& pa, Point& pb) {
  Transform b2a;
  b2a.multInverseLeft(a2w, b2w);
  BBox bb = b.bbox(b2a);
  return common_point(a.root, b, bb, b2a, v, pb, pa);
}
开发者ID:UWEcoCAR,项目名称:car-simulator,代码行数:8,代码来源:Complex.cpp

示例11: PROFILE_SCOPE

void Convex::updateStateList(const MatrixF& mat, const Point3F& scale, const Point3F* displacement)
{
   PROFILE_SCOPE( Convex_UpdateStateList );

   Box3F box1 = getBoundingBox(mat, scale);
   box1.minExtents -= Point3F(1, 1, 1);
   box1.maxExtents += Point3F(1, 1, 1);
   if (displacement) {
      Point3F oldMin = box1.minExtents;
      Point3F oldMax = box1.maxExtents;

      box1.minExtents.setMin(oldMin + *displacement);
      box1.minExtents.setMin(oldMax + *displacement);
      box1.maxExtents.setMax(oldMin + *displacement);
      box1.maxExtents.setMax(oldMax + *displacement);
   }
   sTag++;

   // Destroy states which are no longer intersecting
   for (CollisionStateList* itr = mList.mNext; itr != &mList; itr = itr->mNext) {
      Convex* cv = (itr->mState->a == this)? itr->mState->b: itr->mState->a;
      cv->mTag = sTag;
      if (!box1.isOverlapped(cv->getBoundingBox())) {
         CollisionState* cs = itr->mState;
         itr = itr->mPrev;
         delete cs;
      }
   }

   // Add collision states for new overlapping objects
   for (CollisionWorkingList* itr0 = mWorking.wLink.mNext; itr0 != &mWorking; itr0 = itr0->wLink.mNext) {
      register Convex* cv = itr0->mConvex;
      if (cv->mTag != sTag && box1.isOverlapped(cv->getBoundingBox())) {
         CollisionState* state = new GjkCollisionState;
         state->set(this,cv,mat,cv->getTransform());
         state->mLista->linkAfter(&mList);
         state->mListb->linkAfter(&cv->mList);
      }
   }
}
开发者ID:jamesu,项目名称:libDTShape,代码行数:40,代码来源:convex.cpp

示例12: Convex_Intersects_Polygon

bool Convex_Intersects_Polygon(const Convex &c, const Polygon &p)
{
	LineSegment l;
	l.a = p.p.back();
	for(size_t i = 0; i < p.p.size(); ++i)
	{
		l.b = p.p[i];
		if (c.Intersects(l))
			return true;
		l.a = l.b;
	}

	// Check all the edges of the convex shape against the polygon.
	for(int i = 0; i < c.NumEdges(); ++i)
	{
		l = c.Edge(i);
		if (p.Intersects(l))
			return true;
	}

	return false;
}
开发者ID:Garfield-Chen,项目名称:tng,代码行数:22,代码来源:Polygon.cpp

示例13: main

int main(int argc, char const *argv[])
{
	Convex v1, v2;
	v1.push_back(Point(0,0));
	v1.push_back(Point(1,1));
	v1.push_back(Point(0,2));
	v1.push_back(Point(-1,1));
	v1.push_back(Point(-0.5,0));

	v2.push_back(Point(1,0));
	v2.push_back(Point(2,1));
	v2.push_back(Point(1,2));
	v2.push_back(Point(0,1));
	v2.push_back(Point(0.5,0));

	Convex v = convexIntersection(v1, v2);
	for (int i = 0; i < v.size(); ++i)
	{
		cout << v[i] << endl;
	}
	return 0;
}
开发者ID:JS00000,项目名称:acmCode,代码行数:22,代码来源:3_1_11.cpp

示例14: convex_hull

Convex convex_hull(Convex a) {
    Convex res(2 * a.size() + 5);
    sort(a.begin(), a.end(), comp_less);
    a.erase(unique(a.begin(), a.end()), a.end());
    int m = 0;
    for (int i = 0; i < a.size(); i++) {
        while (m > 1 && sgn(cross(res[m-1]-res[m-2], a[i]-res[m-2])) <= 0) {
            m--;
        }
        res[m++] = a[i];
    }
    int k = m;
    for (int i = a.size() - 2; i >= 0; i--) {
        while (m > k && sgn(cross(res[m-1]-res[m-2], a[i]-res[m-2])) <= 0) {
            m--;
        }
        res[m++] = a[i];
    }
    res.resize(m);
    if (a.size() > 1) {
        res.resize(m-1);
    }
    return res;
}
开发者ID:wujysh,项目名称:2015_ACM_Summer_Training,代码行数:24,代码来源:ZOJ_3154_Mixed_Juice.cpp

示例15: Intersects

 bool Intersects(const Convex& other, Point& overlap) const override
 {
     return other.Intersects(*this, overlap);
 }
开发者ID:mraggi,项目名称:Graph,代码行数:4,代码来源:Box.hpp


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