12 #include <Eigen/Geometry> 16 template<
typename HyperplaneType>
void hyperplane(
const HyperplaneType& _plane)
23 enum { Options = HyperplaneType::Options };
27 typedef Matrix<
Scalar, HyperplaneType::AmbientDimAtCompileTime,
28 HyperplaneType::AmbientDimAtCompileTime>
MatrixType;
30 VectorType
p0 = VectorType::Random(dim);
31 VectorType
p1 = VectorType::Random(dim);
33 VectorType n0 = VectorType::Random(dim).normalized();
34 VectorType
n1 = VectorType::Random(dim).normalized();
36 HyperplaneType pl0(n0, p0);
37 HyperplaneType pl1(n1, p1);
38 HyperplaneType pl2 = pl1;
40 Scalar s0 = internal::random<Scalar>();
41 Scalar s1 = internal::random<Scalar>();
56 MatrixType
rot = MatrixType::Random(dim,dim).householderQr().householderQ();
71 .absDistance((rot*scaling*translation) * p1),
Scalar(1) );
75 .absDistance((rot*translation) * p1),
Scalar(1) );
80 const int Dim = HyperplaneType::AmbientDimAtCompileTime;
88 template<
typename Scalar>
void lines()
96 for(
int i = 0;
i < 10;
i++)
98 Vector center = Vector::Random();
99 Vector u = Vector::Random();
100 Vector
v = Vector::Random();
101 Scalar a = internal::random<Scalar>();
102 while (
abs(a-1) <
Scalar(1
e-4)) a = internal::random<Scalar>();
103 while (u.norm() <
Scalar(1
e-4)) u = Vector::Random();
104 while (v.norm() <
Scalar(1
e-4)) v = Vector::Random();
106 HLine line_u = HLine::Through(center + u, center + a*u);
107 HLine line_v = HLine::Through(center + v, center + a*v);
113 Vector
result = line_u.intersection(line_v);
122 CoeffsType converted_coeffs = line_u2.coeffs();
123 if(line_u2.normal().dot(line_u.normal())<
Scalar(0))
124 converted_coeffs = -line_u2.coeffs();
125 VERIFY(line_u.coeffs().isApprox(converted_coeffs));
135 for(
int i = 0;
i < 10;
i++)
137 Vector
v0 = Vector::Random();
138 Vector
v1(v0),
v2(v0);
139 if(internal::random<double>(0,1)>0.25)
140 v1 += Vector::Random();
141 if(internal::random<double>(0,1)>0.25)
142 v2 +=
v1 *
std::pow(internal::random<Scalar>(0,1),internal::random<int>(1,16));
143 if(internal::random<double>(0,1)>0.25)
144 v2 += Vector::Random() *
std::pow(internal::random<Scalar>(0,1),internal::random<int>(1,16));
146 Plane
p0 = Plane::Through(v0,
v1, v2);
163 Scalar* array3u = array3+1;
165 Plane3a *
p1 = ::new(reinterpret_cast<void*>(array1)) Plane3a;
166 Plane3u *
p2 = ::new(reinterpret_cast<void*>(array2)) Plane3u;
167 Plane3u *
p3 = ::new(reinterpret_cast<void*>(array3u)) Plane3u;
169 p1->coeffs().setRandom();
176 #if defined(EIGEN_VECTORIZE) && EIGEN_MAX_STATIC_ALIGN_BYTES > 0 189 CALL_SUBTEST_2( hyperplane_alignment<float>() );
192 CALL_SUBTEST_1( lines<float>() );
193 CALL_SUBTEST_3( lines<double>() );
194 CALL_SUBTEST_2( planes<float>() );
195 CALL_SUBTEST_5( planes<double>() );
int EIGEN_BLAS_FUNC() rot(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar *pc, RealScalar *ps)
#define VERIFY_RAISES_ASSERT(a)
void hyperplane(const HyperplaneType &_plane)
Represents a diagonal matrix with its storage.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Represents a translation transformation.
#define VERIFY_IS_APPROX(a, b)
EIGEN_DEVICE_FUNC const DiagonalVectorType & diagonal() const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
NumTraits< Scalar >::Real RealScalar
void test_geo_hyperplane()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const
#define VERIFY_IS_MUCH_SMALLER_THAN(a, b)
const mpreal dim(const mpreal &a, const mpreal &b, mp_rnd_t r=mpreal::get_default_rnd())
Jet< T, N > pow(const Jet< T, N > &f, double g)
The matrix class, also used for vectors and row-vectors.
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
void hyperplane_alignment()
friend const mpreal dim(const mpreal &a, const mpreal &b, mp_rnd_t rnd_mode)