11#ifndef EIGEN_HYPERPLANE_H
12#define EIGEN_HYPERPLANE_H
33template <
typename _Scalar,
int _AmbientDim,
int _Options>
37 EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim==Dynamic ? Dynamic : _AmbientDim+1)
39 AmbientDimAtCompileTime = _AmbientDim,
42 typedef _Scalar Scalar;
43 typedef typename NumTraits<Scalar>::Real RealScalar;
44 typedef DenseIndex Index;
46 typedef Matrix<Scalar,Index(AmbientDimAtCompileTime)==Dynamic
48 : Index(AmbientDimAtCompileTime)+1,1,Options> Coefficients;
55 template<
int OtherOptions>
62 inline explicit Hyperplane(Index _dim) : m_coeffs(_dim+1) {}
67 inline Hyperplane(
const VectorType& n,
const VectorType& e)
68 : m_coeffs(n.size()+1)
79 : m_coeffs(n.size()+1)
91 result.
normal() = (p1 - p0).unitOrthogonal();
99 static inline Hyperplane Through(
const VectorType& p0,
const VectorType& p1,
const VectorType& p2)
101 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 3)
103 VectorType v0(p2 - p0), v1(p1 - p0);
104 result.
normal() = v0.cross(v1);
105 RealScalar norm = result.
normal().norm();
106 if(norm <= v0.norm() * v1.
norm() * NumTraits<RealScalar>::epsilon())
132 inline Index
dim()
const {
return AmbientDimAtCompileTime==Dynamic ? m_coeffs.size()-1 : Index(AmbientDimAtCompileTime); }
137 m_coeffs /=
normal().norm();
157 inline ConstNormalReturnType
normal()
const {
return ConstNormalReturnType(m_coeffs,0,0,
dim(),1); }
162 inline NormalReturnType
normal() {
return NormalReturnType(m_coeffs,0,0,
dim(),1); }
167 inline const Scalar&
offset()
const {
return m_coeffs.coeff(
dim()); }
176 inline const Coefficients&
coeffs()
const {
return m_coeffs; }
181 inline Coefficients&
coeffs() {
return m_coeffs; }
192 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)
196 if(internal::isMuchSmallerThan(det, Scalar(1)))
205 Scalar invdet = Scalar(1) / det;
217 template<
typename XprType>
223 m_coeffs /=
normal().norm();
229 eigen_assert(0 &&
"invalid traits value in Hyperplane::transform()");
241 template<
int TrOptions>
255 template<
typename NewScalarType>
256 inline typename internal::cast_return_type<
Hyperplane,
259 return typename internal::cast_return_type<
Hyperplane,
264 template<
typename OtherScalarType,
int OtherOptions>
272 template<
int OtherOptions>
274 {
return m_coeffs.isApprox(other.m_coeffs, prec); }
278 Coefficients m_coeffs;
Expression of a fixed-size or dynamic-size block.
Definition Block.h:104
Eigen::Transpose< Derived > transpose()
Definition Transpose.h:199
ColXpr col(Index i)
Definition DenseBase.h:733
A hyperplane.
Definition Hyperplane.h:35
Coefficients & coeffs()
Definition Hyperplane.h:181
Hyperplane(const Hyperplane< OtherScalarType, AmbientDimAtCompileTime, OtherOptions > &other)
Definition Hyperplane.h:265
static Hyperplane Through(const VectorType &p0, const VectorType &p1)
Definition Hyperplane.h:88
NormalReturnType normal()
Definition Hyperplane.h:162
Hyperplane(const VectorType &n, const Scalar &d)
Definition Hyperplane.h:78
Scalar signedDistance(const VectorType &p) const
Definition Hyperplane.h:143
bool isApprox(const Hyperplane< Scalar, AmbientDimAtCompileTime, OtherOptions > &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition Hyperplane.h:273
Hyperplane & transform(const Transform< Scalar, AmbientDimAtCompileTime, Affine, TrOptions > &t, TransformTraits traits=Affine)
Definition Hyperplane.h:242
void normalize(void)
Definition Hyperplane.h:135
Hyperplane(const ParametrizedLine< Scalar, AmbientDimAtCompileTime > ¶metrized)
Definition Hyperplane.h:123
const Coefficients & coeffs() const
Definition Hyperplane.h:176
internal::cast_return_type< Hyperplane, Hyperplane< NewScalarType, AmbientDimAtCompileTime, Options > >::type cast() const
Definition Hyperplane.h:257
VectorType intersection(const Hyperplane &other) const
Definition Hyperplane.h:189
Hyperplane & transform(const MatrixBase< XprType > &mat, TransformTraits traits=Affine)
Definition Hyperplane.h:218
ConstNormalReturnType normal() const
Definition Hyperplane.h:157
static Hyperplane Through(const VectorType &p0, const VectorType &p1, const VectorType &p2)
Definition Hyperplane.h:99
VectorType projection(const VectorType &p) const
Definition Hyperplane.h:152
Index dim() const
Definition Hyperplane.h:132
Hyperplane(Index _dim)
Definition Hyperplane.h:62
Hyperplane(const VectorType &n, const VectorType &e)
Definition Hyperplane.h:67
Scalar & offset()
Definition Hyperplane.h:171
const Scalar & offset() const
Definition Hyperplane.h:167
Scalar absDistance(const VectorType &p) const
Definition Hyperplane.h:148
Hyperplane()
Definition Hyperplane.h:53
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition JacobiSVD.h:521
const MatrixVType & matrixV() const
Definition JacobiSVD.h:649
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
const internal::inverse_impl< Derived > inverse() const
Definition Inverse.h:320
PlainObject unitOrthogonal(void) const
Definition OrthoMethods.h:210
RealScalar norm() const
Definition Dot.h:125
internal::scalar_product_traits< typenameinternal::traits< Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > >::Scalar, typenameinternal::traits< OtherDerived >::Scalar >::ReturnType dot(const MatrixBase< OtherDerived > &other) const
Definition Dot.h:63
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:129
A parametrized line.
Definition ParametrizedLine.h:31
TransformTraits
Definition Constants.h:389
@ ComputeFullV
Definition Constants.h:331
@ Affine
Definition Constants.h:394
@ Isometry
Definition Constants.h:391