9 #ifndef ApproxMVBB_ProjectedPointSet_hpp 10 #define ApproxMVBB_ProjectedPointSet_hpp 14 #include ApproxMVBB_AssertionDebug_INCLUDE_FILE 15 #include ApproxMVBB_TypeDefs_INCLUDE_FILE 21 #include ApproxMVBB_OOBB_INCLUDE_FILE 29 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
33 template<
typename Derived>
35 const MatrixBase<Derived> & points,
38 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived,3,Eigen::Dynamic)
40 using namespace PointFunctions;
46 std::pair<Vector2,Vector2> pp = estimateDiameter<2>(m_p,epsilon);
49 Vector2 dirX = pp.first - pp.second;
50 if( ( pp.second.array() >= pp.first.array()).all() ) {
59 if( !dirX.allFinite() ) {
67 A2_MK.transposeInPlace();
71 auto size = m_p.cols();
72 for(
unsigned int i=0; i < size; ++i) {
73 p.noalias() = A2_MK * m_p.col(i);
82 M_min(2) = m_minZValue;
86 M_max(2) = m_maxZValue;
92 A_KM.block<2,2>(0,0) = A2_MK.transpose();
97 return OOBB(M_min,M_max, m_A_KI.transpose()*A_KM );
104 template<
typename Derived>
106 const MatrixBase<Derived> & points ) {
108 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived,3,Eigen::Dynamic)
110 using namespace CoordinateSystem;
141 A2_KM.col(0) = rect.m_u;
142 A2_KM.col(1) = rect.m_v;
144 Vector2 M_p = A2_KM.transpose()*rect.m_p;
147 M_min.head<2>() = M_p;
148 M_min(2) = m_minZValue;
150 Vector3 M_max(rect.m_uL, rect.m_vL, 0.0);
151 M_max.head<2>() += M_p;
152 M_max(2) = m_maxZValue;
159 A_IM.block<2,2>(0,0) = A2_KM;
161 A_IM = m_A_KI.transpose()*A_IM;
163 return OOBB(M_min,M_max, A_IM );
169 template<
typename Derived>
170 void project(
const MatrixBase<Derived> & points) {
171 using namespace CoordinateSystem;
173 if(points.cols()==0) {
183 m_A_KI.col(0) = xDir;
184 m_A_KI.col(1) = yDir;
185 m_A_KI.col(2) = m_zDir;
186 m_A_KI.transposeInPlace();
188 "Not orthogonal: x:"<<xDir.transpose()<<
" y: "<< yDir.transpose() <<
" z: " << m_zDir.transpose());
191 auto size = points.cols();
195 m_maxZValue = std::numeric_limits<PREC>::lowest();
196 m_minZValue = std::numeric_limits<PREC>::max();
197 for(decltype(size) i=0; i<size; ++i) {
198 p = m_A_KI*points.col(i);
199 m_p.col(i) = p.head<2>();
200 m_maxZValue = std::max(m_maxZValue,p(2));
201 m_minZValue = std::min(m_minZValue,p(2));
#define ApproxMVBB_ASSERTMSG(condition, message)
An Assert Macro to use within C++ code.
AABB & unite(const MatrixBase< Derived > &p)
VectorStat< Dim > m_minPoint
OOBB computeMVBB(const Vector3 &zDir, const MatrixBase< Derived > &points)
These are some container definitions.
Eigen::Matrix< Scalar, 2, 2 > Matrix22
#define ApproxMVBB_ERRORMSG(message)
VectorStat< Dim > m_maxPoint
MatrixStatDyn< 2 > Matrix2Dyn
Eigen::Matrix< Scalar, 3, 3 > Matrix33
void project(const MatrixBase< Derived > &points)
#define ApproxMVBB_DEFINE_POINTS_CONFIG_TYPES
void makeCoordinateSystem(Vector3 &v1, Vector3 &v2, Vector3 &v3)
This function makes an orthogonal normed right-hand coordinate system. If the z-axis is the input...
EIGEN_MAKE_ALIGNED_OPERATOR_NEW ApproxMVBB_DEFINE_MATRIX_TYPES ApproxMVBB_DEFINE_POINTS_CONFIG_TYPES OOBB computeMVBBApprox(const Vector3 &zDir, const MatrixBase< Derived > &points, const PREC epsilon)
bool checkOrthogonality(Vector3 &v1, Vector3 &v2, Vector3 &v3, PREC eps=1e-6)
Eigen::Matrix< Scalar, 2, 1 > Vector2
Matrix2Dyn m_p
Projected points in frame K.
Matrix33 m_A_KI
Transformation from I frame into the projection frame K.
Eigen::Matrix< Scalar, 3, 1 > Vector3
#define ApproxMVBB_DEFINE_MATRIX_TYPES
const Box2d & getMinRectangle()