11 #ifndef EIGEN_HYPERPLANE_H 12 #define EIGEN_HYPERPLANE_H 15 #include "./InternalHeaderCheck.h" 36 template <
typename Scalar_,
int AmbientDim_,
int Options_>
39 EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar_,
41 enum { AmbientDimAtCompileTime = AmbientDim_, Options = Options_ };
42 typedef Scalar_ Scalar;
43 typedef typename NumTraits<Scalar>::Real RealScalar;
55 template <
int OtherOptions>
57 : m_coeffs(other.
coeffs()) {}
85 result.
normal() = (p1 - p0).unitOrthogonal();
86 result.offset() = -p0.dot(result.normal());
94 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(
VectorType, 3)
97 result.normal() = v0.cross(v1);
98 RealScalar norm = result.normal().norm();
101 m << v0.transpose(), v1.transpose();
103 result.normal() = svd.
matrixV().col(2);
105 result.normal() /= norm;
106 result.offset() = -p0.dot(result.normal());
116 normal() = parametrized.direction().unitOrthogonal();
124 return AmbientDimAtCompileTime ==
Dynamic ? m_coeffs.size() - 1 :
Index(AmbientDimAtCompileTime);
159 EIGEN_DEVICE_FUNC
inline const Scalar&
offset()
const {
return m_coeffs.
coeff(
dim()); }
163 EIGEN_DEVICE_FUNC
inline Scalar&
offset() {
return m_coeffs(
dim()); }
182 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(
VectorType, 2)
186 if (internal::isMuchSmallerThan(det, Scalar(1))) {
188 if (numext::abs(
coeffs().coeff(1)) > numext::abs(
coeffs().coeff(0)))
193 Scalar invdet = Scalar(1) / det;
195 invdet * (
coeffs().coeff(1) * other.coeffs().coeff(2) - other.coeffs().coeff(1) *
coeffs().
coeff(2)),
206 template <
typename XprType>
210 m_coeffs /=
normal().norm();
214 eigen_assert(0 &&
"invalid traits value in Hyperplane::transform()");
226 template <
int TrOptions>
239 template <
typename NewScalarType>
240 EIGEN_DEVICE_FUNC
inline 241 typename internal::cast_return_type<
Hyperplane,
245 typename internal::cast_return_type<
Hyperplane,
250 template <
typename OtherScalarType,
int OtherOptions>
253 m_coeffs = other.coeffs().template cast<Scalar>();
260 template <
int OtherOptions>
264 return m_coeffs.isApprox(other.m_coeffs, prec);
268 Coefficients m_coeffs;
273 #endif // EIGEN_HYPERPLANE_H
VectorType intersection(const Hyperplane &other) const
Definition: Hyperplane.h:181
static Hyperplane Through(const VectorType &p0, const VectorType &p1)
Definition: Hyperplane.h:83
Hyperplane(const VectorType &n, const VectorType &e)
Definition: Hyperplane.h:66
NormalReturnType normal()
Definition: Hyperplane.h:154
Hyperplane(Index _dim)
Definition: Hyperplane.h:61
ConstNormalReturnType normal() const
Definition: Hyperplane.h:147
Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1
Definition: Constants.h:455
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:232
Hyperplane(const VectorType &n, const Scalar &d)
Definition: Hyperplane.h:75
const Scalar & offset() const
Definition: Hyperplane.h:159
Coefficients & coeffs()
Definition: Hyperplane.h:173
Hyperplane()
Definition: Hyperplane.h:53
A hyperplane.
Definition: ForwardDeclarations.h:473
TransformTraits
Definition: Constants.h:453
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
Scalar & offset()
Definition: Hyperplane.h:163
void normalize(void)
Definition: Hyperplane.h:128
Scalar absDistance(const VectorType &p) const
Definition: Hyperplane.h:138
const Coefficients & coeffs() const
Definition: Hyperplane.h:168
const Inverse< Derived > inverse() const
Definition: InverseImpl.h:279
Scalar signedDistance(const VectorType &p) const
Definition: Hyperplane.h:133
constexpr const Scalar & coeff(Index rowId, Index colId) const
Definition: PlainObjectBase.h:172
bool isApprox(const Hyperplane< Scalar, AmbientDimAtCompileTime, OtherOptions > &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Hyperplane.h:261
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:109
VectorType projection(const VectorType &p) const
Definition: Hyperplane.h:142
static Hyperplane Through(const VectorType &p0, const VectorType &p1, const VectorType &p2)
Definition: Hyperplane.h:93
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition: ForwardDeclarations.h:437
internal::cast_return_type< Hyperplane, Hyperplane< NewScalarType, AmbientDimAtCompileTime, Options > >::type cast() const
Definition: Hyperplane.h:243
Hyperplane(const ParametrizedLine< Scalar, AmbientDimAtCompileTime > ¶metrized)
Definition: Hyperplane.h:115
Index dim() const
Definition: Hyperplane.h:123
const MatrixVType & matrixV() const
Definition: SVDBase.h:189
const int Dynamic
Definition: Constants.h:25
Hyperplane(const Hyperplane< OtherScalarType, AmbientDimAtCompileTime, OtherOptions > &other)
Definition: Hyperplane.h:251
Eigen::Index Index
Definition: Hyperplane.h:44
Definition: Constants.h:393
Hyperplane & transform(const Transform< Scalar, AmbientDimAtCompileTime, Affine, TrOptions > &t, TransformTraits traits=Affine)
Definition: Hyperplane.h:227
Definition: Constants.h:458
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
A parametrized line.
Definition: ForwardDeclarations.h:471
Hyperplane & transform(const MatrixBase< XprType > &mat, TransformTraits traits=Affine)
Definition: Hyperplane.h:207