Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "main.h"
00026 #include <Eigen/Geometry>
00027 #include <Eigen/LU>
00028 #include <Eigen/QR>
00029
00030 template<typename BoxType> void alignedbox(const BoxType& _box)
00031 {
00032
00033
00034
00035
00036 const int dim = _box.dim();
00037 typedef typename BoxType::Scalar Scalar;
00038 typedef typename NumTraits<Scalar>::Real RealScalar;
00039 typedef Matrix<Scalar, BoxType::AmbientDimAtCompileTime, 1> VectorType;
00040
00041 VectorType p0 = VectorType::Random(dim);
00042 VectorType p1 = VectorType::Random(dim);
00043 RealScalar s1 = ei_random<RealScalar>(0,1);
00044
00045 BoxType b0(dim);
00046 BoxType b1(VectorType::Random(dim),VectorType::Random(dim));
00047 BoxType b2;
00048
00049 b0.extend(p0);
00050 b0.extend(p1);
00051 VERIFY(b0.contains(p0*s1+(Scalar(1)-s1)*p1));
00052 VERIFY(!b0.contains(p0 + (1+s1)*(p1-p0)));
00053
00054 (b2 = b0).extend(b1);
00055 VERIFY(b2.contains(b0));
00056 VERIFY(b2.contains(b1));
00057 VERIFY_IS_APPROX(b2.clamp(b0), b0);
00058
00059
00060 const int Dim = BoxType::AmbientDimAtCompileTime;
00061 typedef typename GetDifferentType<Scalar>::type OtherScalar;
00062 AlignedBox<OtherScalar,Dim> hp1f = b0.template cast<OtherScalar>();
00063 VERIFY_IS_APPROX(hp1f.template cast<Scalar>(),b0);
00064 AlignedBox<Scalar,Dim> hp1d = b0.template cast<Scalar>();
00065 VERIFY_IS_APPROX(hp1d.template cast<Scalar>(),b0);
00066 }
00067
00068 void test_eigen2_alignedbox()
00069 {
00070 for(int i = 0; i < g_repeat; i++) {
00071 CALL_SUBTEST_1( alignedbox(AlignedBox<float,2>()) );
00072 CALL_SUBTEST_2( alignedbox(AlignedBox<float,3>()) );
00073 CALL_SUBTEST_3( alignedbox(AlignedBox<double,4>()) );
00074 }
00075 }