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;
44 typedef DenseIndex Index;
45 typedef Matrix<Scalar,AmbientDimAtCompileTime,1> VectorType;
46 typedef Matrix<Scalar,Index(AmbientDimAtCompileTime)==
Dynamic
48 : Index(AmbientDimAtCompileTime)+1,1,Options> Coefficients;
49 typedef Block<Coefficients,AmbientDimAtCompileTime,1> NormalReturnType;
50 typedef const Block<const Coefficients,AmbientDimAtCompileTime,1> ConstNormalReturnType;
55 template<
int OtherOptions>
62 inline explicit Hyperplane(Index _dim) : m_coeffs(_dim+1) {}
68 : m_coeffs(n.size()+1)
79 : m_coeffs(n.size()+1)
91 result.
normal() = (p1 - p0).unitOrthogonal();
92 result.offset() = -p0.dot(result.normal());
101 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(
VectorType, 3)
103 result.
normal() = (p2 - p0).cross(p1 - p0).normalized();
104 result.offset() = -p0.dot(result.normal());
115 normal() = parametrized.direction().unitOrthogonal();
122 inline Index
dim()
const {
return AmbientDimAtCompileTime==
Dynamic ? m_coeffs.size()-1 : Index(AmbientDimAtCompileTime); }
127 m_coeffs /=
normal().norm();
157 inline const Scalar&
offset()
const {
return m_coeffs.coeff(
dim()); }
182 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(
VectorType, 2)
183 Scalar det =
coeffs().coeff(0) * other.coeffs().coeff(1) -
coeffs().coeff(1) * other.coeffs().coeff(0);
186 if(internal::isMuchSmallerThan(det, Scalar(1)))
195 Scalar invdet = Scalar(1) / det;
196 return VectorType(invdet*(
coeffs().coeff(1)*other.coeffs().coeff(2)-other.coeffs().coeff(1)*
coeffs().coeff(2)),
197 invdet*(other.coeffs().coeff(0)*
coeffs().coeff(2)-
coeffs().coeff(0)*other.coeffs().coeff(2)));
207 template<
typename XprType>
216 eigen_assert(0 &&
"invalid traits value in Hyperplane::transform()");
228 template<
int TrOptions>
242 template<
typename NewScalarType>
243 inline typename internal::cast_return_type<
Hyperplane,
246 return typename internal::cast_return_type<
Hyperplane,
251 template<
typename OtherScalarType,
int OtherOptions>
253 { m_coeffs = other.coeffs().template cast<Scalar>(); }
259 template<
int OtherOptions>
261 {
return m_coeffs.isApprox(other.m_coeffs, prec); }
265 Coefficients m_coeffs;
270 #endif // EIGEN_HYPERPLANE_H
NormalReturnType normal()
Definition: Hyperplane.h:152
Hyperplane & transform(const Transform< Scalar, AmbientDimAtCompileTime, Affine, TrOptions > &t, TransformTraits traits=Affine)
Definition: Hyperplane.h:229
Hyperplane(const VectorType &n, const VectorType &e)
Definition: Hyperplane.h:67
Hyperplane(const ParametrizedLine< Scalar, AmbientDimAtCompileTime > ¶metrized)
Definition: Hyperplane.h:113
Hyperplane()
Definition: Hyperplane.h:53
internal::cast_return_type< Hyperplane, Hyperplane< NewScalarType, AmbientDimAtCompileTime, Options > >::type cast() const
Definition: Hyperplane.h:244
const Coefficients & coeffs() const
Definition: Hyperplane.h:166
static Hyperplane Through(const VectorType &p0, const VectorType &p1, const VectorType &p2)
Definition: Hyperplane.h:99
Definition: Constants.h:394
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:88
const int Dynamic
Definition: Constants.h:21
Index dim() const
Definition: Hyperplane.h:122
Definition: Constants.h:391
VectorType intersection(const Hyperplane &other) const
Definition: Hyperplane.h:179
Hyperplane(const Hyperplane< OtherScalarType, AmbientDimAtCompileTime, OtherOptions > &other)
Definition: Hyperplane.h:252
Hyperplane(Index _dim)
Definition: Hyperplane.h:62
static Hyperplane Through(const VectorType &p0, const VectorType &p1)
Definition: Hyperplane.h:88
TransformTraits
Definition: Constants.h:389
const internal::inverse_impl< Derived > inverse() const
Definition: Inverse.h:320
Scalar & offset()
Definition: Hyperplane.h:161
A hyperplane.
Definition: ForwardDeclarations.h:263
Coefficients & coeffs()
Definition: Hyperplane.h:171
Scalar signedDistance(const VectorType &p) const
Definition: Hyperplane.h:133
Hyperplane(const VectorType &n, const Scalar &d)
Definition: Hyperplane.h:78
Hyperplane & transform(const MatrixBase< XprType > &mat, TransformTraits traits=Affine)
Definition: Hyperplane.h:208
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:102
VectorType projection(const VectorType &p) const
Definition: Hyperplane.h:142
ConstNormalReturnType normal() const
Definition: Hyperplane.h:147
const Scalar & offset() const
Definition: Hyperplane.h:157
void normalize(void)
Definition: Hyperplane.h:125
Scalar absDistance(const VectorType &p) const
Definition: Hyperplane.h:138
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
A parametrized line.
Definition: ForwardDeclarations.h:262
bool isApprox(const Hyperplane< Scalar, AmbientDimAtCompileTime, OtherOptions > &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Hyperplane.h:260