本文整理汇总了C++中BoxType类的典型用法代码示例。如果您正苦于以下问题:C++ BoxType类的具体用法?C++ BoxType怎么用?C++ BoxType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BoxType类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: alignedbox
template<typename BoxType> void alignedbox(const BoxType& _box)
{
/* this test covers the following files:
AlignedBox.h
*/
typedef typename BoxType::Index Index;
typedef typename BoxType::Scalar Scalar;
typedef typename NumTraits<Scalar>::Real RealScalar;
typedef Matrix<Scalar, BoxType::AmbientDimAtCompileTime, 1> VectorType;
const Index dim = _box.dim();
VectorType p0 = VectorType::Random(dim);
VectorType p1 = VectorType::Random(dim);
while( p1 == p0 ){
p1 = VectorType::Random(dim); }
RealScalar s1 = internal::random<RealScalar>(0,1);
BoxType b0(dim);
BoxType b1(VectorType::Random(dim),VectorType::Random(dim));
BoxType b2;
kill_extra_precision(b1);
kill_extra_precision(p0);
kill_extra_precision(p1);
b0.extend(p0);
b0.extend(p1);
VERIFY(b0.contains(p0*s1+(Scalar(1)-s1)*p1));
VERIFY(b0.contains(b0.center()));
VERIFY(b0.center()==(p0+p1)/Scalar(2));
(b2 = b0).extend(b1);
VERIFY(b2.contains(b0));
VERIFY(b2.contains(b1));
VERIFY_IS_APPROX(b2.clamp(b0), b0);
// intersection
BoxType box1(VectorType::Random(dim));
box1.extend(VectorType::Random(dim));
BoxType box2(VectorType::Random(dim));
box2.extend(VectorType::Random(dim));
VERIFY(box1.intersects(box2) == !box1.intersection(box2).isEmpty());
// alignment -- make sure there is no memory alignment assertion
BoxType *bp0 = new BoxType(dim);
BoxType *bp1 = new BoxType(dim);
bp0->extend(*bp1);
delete bp0;
delete bp1;
// sampling
for( int i=0; i<10; ++i )
{
VectorType r = b0.sample();
VERIFY(b0.contains(r));
}
}
示例2: alignedboxCastTests
void alignedboxCastTests(const BoxType& _box)
{
// casting
typedef typename BoxType::Index Index;
typedef typename BoxType::Scalar Scalar;
typedef typename NumTraits<Scalar>::Real RealScalar;
typedef Matrix<Scalar, BoxType::AmbientDimAtCompileTime, 1> VectorType;
const Index dim = _box.dim();
VectorType p0 = VectorType::Random(dim);
VectorType p1 = VectorType::Random(dim);
BoxType b0(dim);
b0.extend(p0);
b0.extend(p1);
const int Dim = BoxType::AmbientDimAtCompileTime;
typedef typename GetDifferentType<Scalar>::type OtherScalar;
AlignedBox<OtherScalar,Dim> hp1f = b0.template cast<OtherScalar>();
VERIFY_IS_APPROX(hp1f.template cast<Scalar>(),b0);
AlignedBox<Scalar,Dim> hp1d = b0.template cast<Scalar>();
VERIFY_IS_APPROX(hp1d.template cast<Scalar>(),b0);
}
示例3: alignedbox
template<typename BoxType> void alignedbox(const BoxType& _box)
{
/* this test covers the following files:
AlignedBox.h
*/
const int dim = _box.dim();
typedef typename BoxType::Scalar Scalar;
typedef typename NumTraits<Scalar>::Real RealScalar;
typedef Matrix<Scalar, BoxType::AmbientDimAtCompileTime, 1> VectorType;
VectorType p0 = VectorType::Random(dim);
VectorType p1 = VectorType::Random(dim);
RealScalar s1 = ei_random<RealScalar>(0,1);
BoxType b0(dim);
BoxType b1(VectorType::Random(dim),VectorType::Random(dim));
BoxType b2;
b0.extend(p0);
b0.extend(p1);
VERIFY(b0.contains(p0*s1+(Scalar(1)-s1)*p1));
VERIFY(!b0.contains(p0 + (1+s1)*(p1-p0)));
(b2 = b0).extend(b1);
VERIFY(b2.contains(b0));
VERIFY(b2.contains(b1));
VERIFY_IS_APPROX(b2.clamp(b0), b0);
// casting
const int Dim = BoxType::AmbientDimAtCompileTime;
typedef typename GetDifferentType<Scalar>::type OtherScalar;
AlignedBox<OtherScalar,Dim> hp1f = b0.template cast<OtherScalar>();
VERIFY_IS_APPROX(hp1f.template cast<Scalar>(),b0);
AlignedBox<Scalar,Dim> hp1d = b0.template cast<Scalar>();
VERIFY_IS_APPROX(hp1d.template cast<Scalar>(),b0);
}
示例4: minimumOnVolumeObject
double minimumOnVolumeObject(const BoxType &r, const VectorType &v) { ++calls; return r.squaredExteriorDistance(v); }
示例5: minimumOnObjectVolume
double minimumOnObjectVolume(const BallType &b, const BoxType &r) { ++calls; return SQR(std::max(0., r.exteriorDistance(b.center) - b.radius)); }
示例6: minimumOnVolumeVolume
double minimumOnVolumeVolume(const BoxType &r1, const BoxType &r2) { ++calls; return r1.squaredExteriorDistance(r2); }
示例7: minimumOnVolume
double minimumOnVolume(const BoxType &r) { ++calls; return r.squaredExteriorDistance(p); }
示例8: intersectVolumeObject
bool intersectVolumeObject(const BoxType &r, const VectorType &v) { ++calls; return r.contains(v); }
示例9: intersectObjectVolume
bool intersectObjectVolume(const BallType &b, const BoxType &r) { ++calls; return r.squaredExteriorDistance(b.center) < SQR(b.radius); }
示例10: intersectVolumeVolume
bool intersectVolumeVolume(const BoxType &r1, const BoxType &r2) { ++calls; return !(r1.intersection(r2)).isNull(); }
示例11: intersectVolume
bool intersectVolume(const BoxType &r) { ++calls; return r.contains(p); }
示例12: minimumOnVolumeObject
double minimumOnVolumeObject(const BoxType &r, const BallType &b) { ++calls; return SQR((std::max)(0., r.exteriorDistance(b.center) - b.radius)); }