11 #ifndef EIGEN_HYPERPLANE_H 12 #define EIGEN_HYPERPLANE_H 33 template <
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;
55 template<
int OtherOptions>
57 : m_coeffs(other.coeffs())
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)
88 static inline Hyperplane
Through(
const VectorType& p0,
const VectorType& p1)
90 Hyperplane result(p0.size());
91 result.
normal() = (p1 - p0).unitOrthogonal();
92 result.offset() = -p0.dot(result.normal());
99 static inline Hyperplane
Through(
const VectorType& p0,
const VectorType& p1,
const VectorType& p2)
101 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 3)
102 Hyperplane result(p0.size());
103 VectorType v0(p2 - p0), v1(p1 - p0);
104 result.normal() = v0.cross(v1);
105 RealScalar norm = result.normal().norm();
110 result.normal() = svd.
matrixV().col(2);
113 result.normal() /= norm;
114 result.offset() = -p0.dot(result.normal());
125 normal() = parametrized.direction().unitOrthogonal();
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); }
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;
206 return VectorType(invdet*(
coeffs().coeff(1)*other.coeffs().coeff(2)-other.coeffs().coeff(1)*
coeffs().
coeff(2)),
217 template<
typename XprType>
226 eigen_assert(0 &&
"invalid traits value in Hyperplane::transform()");
238 template<
int TrOptions>
252 template<
typename NewScalarType>
253 inline typename internal::cast_return_type<
Hyperplane,
256 return typename internal::cast_return_type<
Hyperplane,
261 template<
typename OtherScalarType,
int OtherOptions>
263 { m_coeffs = other.coeffs().template cast<Scalar>(); }
269 template<
int OtherOptions>
271 {
return m_coeffs.isApprox(other.m_coeffs, prec); }
275 Coefficients m_coeffs;
280 #endif // EIGEN_HYPERPLANE_H
Hyperplane(const VectorType &n, const VectorType &e)
Definition: Hyperplane.h:67
static Hyperplane Through(const VectorType &p0, const VectorType &p1, const VectorType &p2)
Definition: Hyperplane.h:99
Hyperplane(const VectorType &n, const Scalar &d)
Definition: Hyperplane.h:78
const Scalar & offset() const
Definition: Hyperplane.h:167
Hyperplane(Index _dim)
Definition: Hyperplane.h:62
Hyperplane & transform(const MatrixBase< XprType > &mat, TransformTraits traits=Affine)
Definition: Hyperplane.h:218
Namespace containing all symbols from the Eigen library.
Definition: Core:271
Definition: Constants.h:447
Scalar signedDistance(const VectorType &p) const
Definition: Hyperplane.h:143
Hyperplane(const Hyperplane< OtherScalarType, AmbientDimAtCompileTime, OtherOptions > &other)
Definition: Hyperplane.h:262
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:167
VectorType projection(const VectorType &p) const
Definition: Hyperplane.h:152
const Coefficients & coeffs() const
Definition: Hyperplane.h:176
VectorType intersection(const Hyperplane &other) const
Definition: Hyperplane.h:189
Scalar & offset()
Definition: Hyperplane.h:171
TransposeReturnType transpose()
Definition: Transpose.h:167
bool isApprox(const Hyperplane< Scalar, AmbientDimAtCompileTime, OtherOptions > &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Hyperplane.h:270
Coefficients & coeffs()
Definition: Hyperplane.h:181
Index dim() const
Definition: Hyperplane.h:132
A hyperplane.
Definition: ForwardDeclarations.h:276
TransformTraits
Definition: Constants.h:445
Eigen::Index Index
Definition: Hyperplane.h:44
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: XprHelper.h:35
Hyperplane()
Definition: Hyperplane.h:53
Hyperplane(const ParametrizedLine< Scalar, AmbientDimAtCompileTime > ¶metrized)
Definition: Hyperplane.h:123
internal::cast_return_type< Hyperplane, Hyperplane< NewScalarType, AmbientDimAtCompileTime, Options > >::type cast() const
Definition: Hyperplane.h:254
ConstNormalReturnType normal() const
Definition: Hyperplane.h:157
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_abs_op< typename Derived::Scalar >, const Derived > abs(const Eigen::ArrayBase< Derived > &x)
const Inverse< Derived > inverse() const
Definition: InverseImpl.h:331
static Hyperplane Through(const VectorType &p0, const VectorType &p1)
Definition: Hyperplane.h:88
const Scalar & coeff(Index rowId, Index colId) const
Definition: PlainObjectBase.h:154
void normalize(void)
Definition: Hyperplane.h:135
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition: ForwardDeclarations.h:258
Scalar absDistance(const VectorType &p) const
Definition: Hyperplane.h:148
const MatrixVType & matrixV() const
Definition: SVDBase.h:99
const int Dynamic
Definition: Constants.h:21
Definition: Constants.h:387
Definition: Constants.h:450
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
A parametrized line.
Definition: ForwardDeclarations.h:275
Hyperplane & transform(const Transform< Scalar, AmbientDimAtCompileTime, Affine, TrOptions > &t, TransformTraits traits=Affine)
Definition: Hyperplane.h:239
NormalReturnType normal()
Definition: Hyperplane.h:162