mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
add test for geometry with eigen2_ prefixes. fix that stuff.
This commit is contained in:
@@ -22,8 +22,7 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef EIGEN_ALIGNEDBOX_H
|
||||
#define EIGEN_ALIGNEDBOX_H
|
||||
// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
|
||||
|
||||
/** \geometry_module \ingroup Geometry_Module
|
||||
* \nonstableyet
|
||||
@@ -169,5 +168,3 @@ inline Scalar AlignedBox<Scalar,AmbiantDim>::squaredExteriorDistance(const Vecto
|
||||
}
|
||||
return dist2;
|
||||
}
|
||||
|
||||
#endif // EIGEN_ALIGNEDBOX_H
|
||||
|
||||
@@ -58,6 +58,10 @@
|
||||
#define Hyperplane eigen2_Hyperplane
|
||||
#define ParametrizedLine eigen2_ParametrizedLine
|
||||
|
||||
#define ei_toRotationMatrix eigen2_ei_toRotationMatrix
|
||||
#define ei_quaternion_assign_impl eigen2_ei_quaternion_assign_impl
|
||||
#define ei_transform_product_impl eigen2_ei_transform_product_impl
|
||||
|
||||
#include "RotationBase.h"
|
||||
#include "Rotation2D.h"
|
||||
#include "Quaternion.h"
|
||||
@@ -69,6 +73,10 @@
|
||||
#include "Hyperplane.h"
|
||||
#include "ParametrizedLine.h"
|
||||
|
||||
#undef ei_toRotationMatrix
|
||||
#undef ei_quaternion_assign_impl
|
||||
#undef ei_transform_product_impl
|
||||
|
||||
#undef RotationBase
|
||||
#undef Rotation2D
|
||||
#undef Rotation2Df
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef EIGEN_ANGLEAXIS_H
|
||||
#define EIGEN_ANGLEAXIS_H
|
||||
// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
|
||||
|
||||
|
||||
/** \geometry_module \ingroup Geometry_Module
|
||||
*
|
||||
@@ -224,5 +224,3 @@ AngleAxis<Scalar>::toRotationMatrix(void) const
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif // EIGEN_ANGLEAXIS_H
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef EIGEN_HYPERPLANE_H
|
||||
#define EIGEN_HYPERPLANE_H
|
||||
// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
|
||||
|
||||
/** \geometry_module \ingroup Geometry_Module
|
||||
*
|
||||
@@ -71,7 +70,7 @@ public:
|
||||
: m_coeffs(n.size()+1)
|
||||
{
|
||||
normal() = n;
|
||||
offset() = -e.dot(n);
|
||||
offset() = -e.eigen2_dot(n);
|
||||
}
|
||||
|
||||
/** Constructs a plane from its normal \a n and distance to the origin \a d
|
||||
@@ -92,7 +91,7 @@ public:
|
||||
{
|
||||
Hyperplane result(p0.size());
|
||||
result.normal() = (p1 - p0).unitOrthogonal();
|
||||
result.offset() = -result.normal().dot(p0);
|
||||
result.offset() = -result.normal().eigen2_dot(p0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -104,7 +103,7 @@ public:
|
||||
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 3)
|
||||
Hyperplane result(p0.size());
|
||||
result.normal() = (p2 - p0).cross(p1 - p0).normalized();
|
||||
result.offset() = -result.normal().dot(p0);
|
||||
result.offset() = -result.normal().eigen2_dot(p0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -116,7 +115,7 @@ public:
|
||||
explicit Hyperplane(const ParametrizedLine<Scalar, AmbientDimAtCompileTime>& parametrized)
|
||||
{
|
||||
normal() = parametrized.direction().unitOrthogonal();
|
||||
offset() = -normal().dot(parametrized.origin());
|
||||
offset() = -normal().eigen2_dot(parametrized.origin());
|
||||
}
|
||||
|
||||
~Hyperplane() {}
|
||||
@@ -133,7 +132,7 @@ public:
|
||||
/** \returns the signed distance between the plane \c *this and a point \a p.
|
||||
* \sa absDistance()
|
||||
*/
|
||||
inline Scalar signedDistance(const VectorType& p) const { return p.dot(normal()) + offset(); }
|
||||
inline Scalar signedDistance(const VectorType& p) const { return p.eigen2_dot(normal()) + offset(); }
|
||||
|
||||
/** \returns the absolute distance between the plane \c *this and a point \a p.
|
||||
* \sa signedDistance()
|
||||
@@ -231,7 +230,7 @@ public:
|
||||
TransformTraits traits = Affine)
|
||||
{
|
||||
transform(t.linear(), traits);
|
||||
offset() -= t.translation().dot(normal());
|
||||
offset() -= t.translation().eigen2_dot(normal());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -264,5 +263,3 @@ protected:
|
||||
|
||||
Coefficients m_coeffs;
|
||||
};
|
||||
|
||||
#endif // EIGEN_HYPERPLANE_H
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef EIGEN_PARAMETRIZEDLINE_H
|
||||
#define EIGEN_PARAMETRIZEDLINE_H
|
||||
// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
|
||||
|
||||
|
||||
/** \geometry_module \ingroup Geometry_Module
|
||||
*
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
RealScalar squaredDistance(const VectorType& p) const
|
||||
{
|
||||
VectorType diff = p-origin();
|
||||
return (diff - diff.dot(direction())* direction()).squaredNorm();
|
||||
return (diff - diff.eigen2_dot(direction())* direction()).squaredNorm();
|
||||
}
|
||||
/** \returns the distance of a point \a p to its projection onto the line \c *this.
|
||||
* \sa squaredDistance()
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
|
||||
/** \returns the projection of a point \a p onto the line \c *this. */
|
||||
VectorType projection(const VectorType& p) const
|
||||
{ return origin() + (p-origin()).dot(direction()) * direction(); }
|
||||
{ return origin() + (p-origin()).eigen2_dot(direction()) * direction(); }
|
||||
|
||||
Scalar intersection(const Hyperplane<_Scalar, _AmbientDim>& hyperplane);
|
||||
|
||||
@@ -148,8 +148,6 @@ inline ParametrizedLine<_Scalar, _AmbientDim>::ParametrizedLine(const Hyperplane
|
||||
template <typename _Scalar, int _AmbientDim>
|
||||
inline _Scalar ParametrizedLine<_Scalar, _AmbientDim>::intersection(const Hyperplane<_Scalar, _AmbientDim>& hyperplane)
|
||||
{
|
||||
return -(hyperplane.offset()+origin().dot(hyperplane.normal()))
|
||||
/(direction().dot(hyperplane.normal()));
|
||||
return -(hyperplane.offset()+origin().eigen2_dot(hyperplane.normal()))
|
||||
/(direction().eigen2_dot(hyperplane.normal()));
|
||||
}
|
||||
|
||||
#endif // EIGEN_PARAMETRIZEDLINE_H
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef EIGEN_QUATERNION_H
|
||||
#define EIGEN_QUATERNION_H
|
||||
// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
|
||||
|
||||
template<typename Other,
|
||||
int OtherRows=Other::RowsAtCompileTime,
|
||||
@@ -172,7 +171,7 @@ public:
|
||||
* corresponds to the cosine of half the angle between the two rotations.
|
||||
* \sa angularDistance()
|
||||
*/
|
||||
inline Scalar dot(const Quaternion& other) const { return m_coeffs.dot(other.m_coeffs); }
|
||||
inline Scalar eigen2_dot(const Quaternion& other) const { return m_coeffs.eigen2_dot(other.m_coeffs); }
|
||||
|
||||
inline Scalar angularDistance(const Quaternion& other) const;
|
||||
|
||||
@@ -353,7 +352,7 @@ inline Quaternion<Scalar>& Quaternion<Scalar>::setFromTwoVectors(const MatrixBas
|
||||
{
|
||||
Vector3 v0 = a.normalized();
|
||||
Vector3 v1 = b.normalized();
|
||||
Scalar c = v0.dot(v1);
|
||||
Scalar c = v0.eigen2_dot(v1);
|
||||
|
||||
// if dot == 1, vectors are the same
|
||||
if (ei_isApprox(c,Scalar(1)))
|
||||
@@ -412,12 +411,12 @@ inline Quaternion<Scalar> Quaternion<Scalar>::conjugate() const
|
||||
}
|
||||
|
||||
/** \returns the angle (in radian) between two rotations
|
||||
* \sa dot()
|
||||
* \sa eigen2_dot()
|
||||
*/
|
||||
template <typename Scalar>
|
||||
inline Scalar Quaternion<Scalar>::angularDistance(const Quaternion& other) const
|
||||
{
|
||||
double d = ei_abs(this->dot(other));
|
||||
double d = ei_abs(this->eigen2_dot(other));
|
||||
if (d>=1.0)
|
||||
return 0;
|
||||
return Scalar(2) * std::acos(d);
|
||||
@@ -430,7 +429,7 @@ template <typename Scalar>
|
||||
Quaternion<Scalar> Quaternion<Scalar>::slerp(Scalar t, const Quaternion& other) const
|
||||
{
|
||||
static const Scalar one = Scalar(1) - machine_epsilon<Scalar>();
|
||||
Scalar d = this->dot(other);
|
||||
Scalar d = this->eigen2_dot(other);
|
||||
Scalar absD = ei_abs(d);
|
||||
|
||||
Scalar scale0;
|
||||
@@ -505,5 +504,3 @@ struct ei_quaternion_assign_impl<Other,4,1>
|
||||
q.coeffs() = vec;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // EIGEN_QUATERNION_H
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef EIGEN_ROTATION2D_H
|
||||
#define EIGEN_ROTATION2D_H
|
||||
// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
|
||||
|
||||
|
||||
/** \geometry_module \ingroup Geometry_Module
|
||||
*
|
||||
@@ -155,5 +155,3 @@ Rotation2D<Scalar>::toRotationMatrix(void) const
|
||||
Scalar cosA = ei_cos(m_angle);
|
||||
return (Matrix2() << cosA, -sinA, sinA, cosA).finished();
|
||||
}
|
||||
|
||||
#endif // EIGEN_ROTATION2D_H
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef EIGEN_ROTATIONBASE_H
|
||||
#define EIGEN_ROTATIONBASE_H
|
||||
// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
|
||||
|
||||
// this file aims to contains the various representations of rotation/orientation
|
||||
// in 2D and 3D space excepted Matrix and Quaternion.
|
||||
@@ -133,5 +132,3 @@ inline static const MatrixBase<OtherDerived>& ei_toRotationMatrix(const MatrixBa
|
||||
YOU_MADE_A_PROGRAMMING_MISTAKE)
|
||||
return mat;
|
||||
}
|
||||
|
||||
#endif // EIGEN_ROTATIONBASE_H
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef EIGEN_SCALING_H
|
||||
#define EIGEN_SCALING_H
|
||||
// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
|
||||
|
||||
|
||||
/** \geometry_module \ingroup Geometry_Module
|
||||
*
|
||||
@@ -177,5 +177,3 @@ Scaling<Scalar,Dim>::operator* (const TransformType& t) const
|
||||
res.prescale(m_coeffs);
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif // EIGEN_SCALING_H
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef EIGEN_TRANSFORM_H
|
||||
#define EIGEN_TRANSFORM_H
|
||||
// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
|
||||
|
||||
|
||||
// Note that we have to pass Dim and HDim because it is not allowed to use a template
|
||||
// parameter to define a template specialization. To be more precise, in the following
|
||||
@@ -796,5 +796,3 @@ struct ei_transform_product_impl<Other,Dim,HDim, Dim,1>
|
||||
{ return ((tr.linear() * other) + tr.translation())
|
||||
* (Scalar(1) / ( (tr.matrix().template block<1,Dim>(Dim,0) * other).coeff(0) + tr.matrix().coeff(Dim,Dim))); }
|
||||
};
|
||||
|
||||
#endif // EIGEN_TRANSFORM_H
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef EIGEN_TRANSLATION_H
|
||||
#define EIGEN_TRANSLATION_H
|
||||
// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
|
||||
|
||||
|
||||
/** \geometry_module \ingroup Geometry_Module
|
||||
*
|
||||
@@ -194,5 +194,3 @@ Translation<Scalar,Dim>::operator* (const TransformType& t) const
|
||||
res.pretranslate(m_coeffs);
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif // EIGEN_TRANSLATION_H
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef EIGEN_LEASTSQUARES_H
|
||||
#define EIGEN_LEASTSQUARES_H
|
||||
#ifndef EIGEN2_LEASTSQUARES_H
|
||||
#define EIGEN2_LEASTSQUARES_H
|
||||
|
||||
/** \ingroup LeastSquares_Module
|
||||
*
|
||||
@@ -179,4 +179,4 @@ void fitHyperplane(int numPoints,
|
||||
}
|
||||
|
||||
|
||||
#endif // EIGEN_LEASTSQUARES_H
|
||||
#endif // EIGEN2_LEASTSQUARES_H
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef EIGEN_SVD_H
|
||||
#define EIGEN_SVD_H
|
||||
#ifndef EIGEN2_SVD_H
|
||||
#define EIGEN2_SVD_H
|
||||
|
||||
/** \ingroup SVD_Module
|
||||
* \nonstableyet
|
||||
@@ -150,7 +150,7 @@ void SVD<MatrixType>::compute(const MatrixType& matrix)
|
||||
if ((k < nct) && (m_sigma[k] != 0.0))
|
||||
{
|
||||
// Apply the transformation.
|
||||
Scalar t = matA.col(k).end(m-k).dot(matA.col(j).end(m-k)); // FIXME dot product or cwise prod + .sum() ??
|
||||
Scalar t = matA.col(k).end(m-k).eigen2_dot(matA.col(j).end(m-k)); // FIXME dot product or cwise prod + .sum() ??
|
||||
t = -t/matA(k,k);
|
||||
matA.col(j).end(m-k) += t * matA.col(k).end(m-k);
|
||||
}
|
||||
@@ -216,7 +216,7 @@ void SVD<MatrixType>::compute(const MatrixType& matrix)
|
||||
{
|
||||
for (j = k+1; j < nu; ++j)
|
||||
{
|
||||
Scalar t = m_matU.col(k).end(m-k).dot(m_matU.col(j).end(m-k)); // FIXME is it really a dot product we want ?
|
||||
Scalar t = m_matU.col(k).end(m-k).eigen2_dot(m_matU.col(j).end(m-k)); // FIXME is it really a dot product we want ?
|
||||
t = -t/m_matU(k,k);
|
||||
m_matU.col(j).end(m-k) += t * m_matU.col(k).end(m-k);
|
||||
}
|
||||
@@ -242,7 +242,7 @@ void SVD<MatrixType>::compute(const MatrixType& matrix)
|
||||
{
|
||||
for (j = k+1; j < nu; ++j)
|
||||
{
|
||||
Scalar t = m_matV.col(k).end(n-k-1).dot(m_matV.col(j).end(n-k-1)); // FIXME is it really a dot product we want ?
|
||||
Scalar t = m_matV.col(k).end(n-k-1).eigen2_dot(m_matV.col(j).end(n-k-1)); // FIXME is it really a dot product we want ?
|
||||
t = -t/m_matV(k+1,k);
|
||||
m_matV.col(j).end(n-k-1) += t * m_matV.col(k).end(n-k-1);
|
||||
}
|
||||
@@ -646,4 +646,4 @@ MatrixBase<Derived>::svd() const
|
||||
return SVD<PlainObject>(derived());
|
||||
}
|
||||
|
||||
#endif // EIGEN_SVD_H
|
||||
#endif // EIGEN2_SVD_H
|
||||
|
||||
Reference in New Issue
Block a user