Skip to content

Commit

Permalink
Seems to compile
Browse files Browse the repository at this point in the history
  • Loading branch information
gabyx committed Sep 18, 2018
1 parent 03a3a0e commit 9e73449
Show file tree
Hide file tree
Showing 16 changed files with 164 additions and 137 deletions.
1 change: 1 addition & 0 deletions cmake/DefineApproxMVBBSources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ macro(INCLUDE_ALL_ApproxMVBB_SOURCE
${ApproxMVBB_ROOT_DIR}/src/ApproxMVBB/RandomGenerators.cpp
${ApproxMVBB_ROOT_DIR}/src/ApproxMVBB/ConvexHull2D.cpp
${ApproxMVBB_ROOT_DIR}/src/ApproxMVBB/MinAreaRectangle.cpp
${ApproxMVBB_ROOT_DIR}/src/ApproxMVBB/ProjectedPointSet.cpp
${ApproxMVBB_ROOT_DIR}/src/ApproxMVBB/OOBB.cpp
${ApproxMVBB_ROOT_DIR}/src/ApproxMVBB/AABB.cpp

Expand Down
16 changes: 8 additions & 8 deletions example/approxMVBB/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int main(int argc, char** argv)
{
unsigned int nPoints = 100000;

std::cout << "Sample " << nPoints << " points in unite cube (coordinates are in world frame I) " << std::endl;
std::cout << "Sample " << nPoints << " points in unite cube (coordinates are in world coordinate system `I` ) " << std::endl;
ApproxMVBB::Matrix3Dyn points(3, nPoints);
points.setRandom();

Expand All @@ -28,14 +28,14 @@ int main(int argc, char** argv)
5);

std::cout << "Computed OOBB: " << std::endl
<< "---> lower point in OOBB frame: " << oobb.m_minPoint.transpose() << std::endl
<< "---> upper point in OOBB frame: " << oobb.m_maxPoint.transpose() << std::endl
<< "---> coordinate transformation A_IK matrix from OOBB frame K "
"to world frame I"
<< "---> lower point in OOBB coordinate system: " << oobb.m_minPoint.transpose() << std::endl
<< "---> upper point in OOBB coordinate system: " << oobb.m_maxPoint.transpose() << std::endl
<< "---> coordinate transformation A_IK matrix from OOBB coordinate system `K` "
"to world coordinate system `I` "
<< std::endl
<< oobb.m_q_KI.matrix() << std::endl
<< "---> this is also the rotation matrix R_KI which turns the "
"world frame I into the OOBB frame K"
"world coordinate system `I` into the OOBB coordinate system `K` "
<< std::endl
<< std::endl;

Expand All @@ -52,8 +52,8 @@ int main(int argc, char** argv)
oobb.expandToMinExtentAbsolute(0.1);

std::cout << "OOBB with all point included: " << std::endl
<< "---> lower point in OOBB frame: " << oobb.m_minPoint.transpose() << std::endl
<< "---> upper point in OOBB frame: " << oobb.m_maxPoint.transpose() << std::endl;
<< "---> lower point in OOBB coordinate system: " << oobb.m_minPoint.transpose() << std::endl
<< "---> upper point in OOBB coordinate system: " << oobb.m_maxPoint.transpose() << std::endl;

return 0;
}
7 changes: 7 additions & 0 deletions include/ApproxMVBB/AngleFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@
#ifndef ApproxMVBB_AngleFunctions_hpp
#define ApproxMVBB_AngleFunctions_hpp

#define _USE_MATH_DEFINES
#include <cmath>
#include "ApproxMVBB/Config/Config.hpp"
#include ApproxMVBB_TypeDefs_INCLUDE_FILE

#define _USE_MATH_DEFINES
#ifndef M_PI
# define M_PI 3.14159265358979323846
#endif

namespace ApproxMVBB
{
namespace AngleFunctions
Expand Down
2 changes: 1 addition & 1 deletion include/ApproxMVBB/ComputeApproxMVBB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ namespace ApproxMVBB
// Define the volume lower bound above we accept a new volume as
// PREC volumeAcceptTol = oobb.volume() * volumeAcceptFactor;

// Get the direction of the input OOBB in I frame:
// Get the direction of the input OOBB in coordinate system `I` :
Vector3 dir1 = oobb.getDirection(0);
Vector3 dir2 = oobb.getDirection(1);
Vector3 dir3 = oobb.getDirection(2);
Expand Down
4 changes: 2 additions & 2 deletions include/ApproxMVBB/KdTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1607,9 +1607,9 @@ namespace ApproxMVBB
}

/** Get cell index of the leaf which owns point \p point
* \p point is the d-dimensional point in the frame of reference the kd-Tree
* \p point is the d-dimensional point in the coordinate system the kd-Tree
* was built!
* Points outside the roots AABB box, are naturally project to the most outer
* Points outside the root AABB box, are naturally project to the most outer
* leaf automatically.
*/
template<typename Derived>
Expand Down
26 changes: 13 additions & 13 deletions include/ApproxMVBB/OOBB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace ApproxMVBB
void reset();

/** Add points to this OOBB. The points `p` are assumed to be
represented in this OOBB's coordinate system K. */
represented in this OOBB's coordinate system `K` . */
template<typename Derived>
OOBB& unite(const MatrixBase<Derived>& p)
{
Expand All @@ -89,13 +89,13 @@ namespace ApproxMVBB
return *this;
}

/** Get the center of the OOBB represented in coordinate system K. */
/** Get the center of the OOBB represented in coordinate system `K` . */
inline Vector3 center()
{
return 0.5 * (m_maxPoint + m_minPoint);
}

/** Get the extent of the OOBB represented in coordinate system K. */
/** Get the extent of the OOBB represented in coordinate system `K` . */
inline Array3 extent() const
{
return (m_maxPoint - m_minPoint).array();
Expand All @@ -122,14 +122,14 @@ namespace ApproxMVBB
/** Checks if a point overlaps the OOBB
@param p Input point.
@param coordinateSystemIsI Determines if the the input point is represented in
the coordinate system I or if false they are represented in
the coordinate system of the OOBB (coordinate system K). */
the coordinate system `I` or if false they are represented in
the coordinate system of the OOBB (coordinate system `K` ). */
template<typename Derived, bool coordinateSystemIsI = true>
inline bool overlaps(const MatrixBase<Derived>& p) const
{
if(coordinateSystemIsI)
{
// p is in I frame
// p is in coordinate system `I`
Vector3 t = m_q_KI.inverse() * p; // A_IK^T * I_p
return ((t.array() >= m_minPoint.array()) && (t.array() <= m_maxPoint.array())).all();
}
Expand Down Expand Up @@ -164,7 +164,7 @@ namespace ApproxMVBB
return d(0) * d(1) * d(2);
}

/** Get direction vectors in the coordinate system I. */
/** Get direction vectors in the coordinate system `I` . */
inline Vector3 getDirection(unsigned int i) const
{
ApproxMVBB_ASSERTMSG(i < 3, "Index wrong: " << i) Vector3 d = Vector3::Zero();
Expand All @@ -174,9 +174,9 @@ namespace ApproxMVBB

/** Get all corner points of the OOBB.
@param coordinateSystemIsI Determines if the the output points are represented in
the coordinate system I or if false they are represented in
the coordinate system of the OOBB (coordinate system K).
@return A list of all corner points sorted according to (x,y,z) index in coordinate system K. */
the coordinate system `I` or if false they are represented in
the coordinate system of the OOBB (coordinate system `K` ).
@return A list of all corner points sorted according to (x,y,z) index in coordinate system `K` . */
template<bool coordinateSystemIsI = true>
inline Vector3List getCornerPoints() const
{
Expand All @@ -203,10 +203,10 @@ namespace ApproxMVBB
return points;
}

Quaternion m_q_KI; /**< Rotation of coordinate system I to the coordinate system K (OOBB),
Quaternion m_q_KI; /**< Rotation of coordinate system `I` to the coordinate system `K` (OOBB),
corresponds to a transformation A_IK. */
Vector3 m_minPoint; //!< Minimal Point. Represented in coordinate system K (OOBB).
Vector3 m_maxPoint; //!< Maximal Point. Represented in coordinate system K (OOBB).
Vector3 m_minPoint; //!< Minimal Point. Represented in coordinate system `K` (OOBB).
Vector3 m_maxPoint; //!< Maximal Point. Represented in coordinate system `K` (OOBB).
};
} // namespace ApproxMVBB

Expand Down
21 changes: 13 additions & 8 deletions include/ApproxMVBB/ProjectedPointSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ namespace ApproxMVBB
ApproxMVBB_DEFINE_MATRIX_TYPES;
ApproxMVBB_DEFINE_POINTS_CONFIG_TYPES;

public:
ProjectedPointSet();
~ProjectedPointSet();

public:
template<typename Derived>
OOBB computeMVBBApprox(const Vector3& zDir, const MatrixBase<Derived>& points, const PREC epsilon)
{
Expand All @@ -50,7 +55,7 @@ namespace ApproxMVBB
}
// std::cout <<"estimated 2d diameter: " << dirX.transpose() << " eps: " <<
// epsilon << std::endl;
// Built Coordinate Trafo from frame K to frame M
// Built Coordinate Trafo from coordinate system `K` to coordinate system `M`
Matrix22 A2_MK;
dirX.normalize();

Expand Down Expand Up @@ -88,8 +93,8 @@ namespace ApproxMVBB
M_max.head<2>() = aabb.m_maxPoint;
M_max(2) = m_maxZValue;

// Make coordinate transformation from M frame (Minimum Rectancle)
// to K frame (Projection Plane);
// Make coordinate transformation from `M` coordinate system (Minimum Rectancle)
// to `K` coordinate system (Projection Plane);
Matrix33 A_KM;
A_KM.setIdentity();
A_KM.block<2, 2>(0, 0) = A2_MK.transpose();
Expand Down Expand Up @@ -152,8 +157,8 @@ namespace ApproxMVBB
M_max.head<2>() += M_p;
M_max(2) = m_maxZValue;

// Make coordinate transformation from M frame (Minimum Rectancle)
// to K frame (Projection Plane);
// Make coordinate transformation from `M` coordinate system (Minimum Rectancle)
// to `K` coordinate system (Projection Plane);
Matrix33 A_IM;
// Make A_KM
A_IM.setIdentity();
Expand All @@ -180,7 +185,7 @@ namespace ApproxMVBB
// std::cout << "dir: " << m_zDir << std::endl;
makeCoordinateSystem(m_zDir, xDir, yDir);

// Make coodinate transform from frame I to K!
// Make coodinate transform from coordinate system `I` to K!
m_A_KI.col(0) = xDir;
m_A_KI.col(1) = yDir;
m_A_KI.col(2) = m_zDir;
Expand All @@ -205,10 +210,10 @@ namespace ApproxMVBB
}
}

Matrix2Dyn m_p; ///< Projected points in frame K
Matrix2Dyn m_p; ///< Projected points in coordinate system `K`

Vector3 m_zDir;
Matrix33 m_A_KI; ///< Transformation from I frame into the projection frame K
Matrix33 m_A_KI; ///< Transformation from coordinate system `I` into the projection coordinate system `K`
PREC m_minZValue, m_maxZValue;
};
} // namespace ApproxMVBB
Expand Down
4 changes: 2 additions & 2 deletions src/ApproxMVBB/OOBB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace ApproxMVBB
if(i == 0)
{
// Make new x-Axis the z-Axis
// R_NK = Rotate around 90∞ around Y, and 90∞ around X (always in K frame) )
// R_NK = Rotate around 90∞ around Y, and 90∞ around X (always in `K` coordinate system) )
// A_IN = A_IK * A_KN = R_KI * R_NK
m_q_KI = m_q_KI * Quaternion(0.5, 0.5, 0.5, 0.5);
// Change points Coordinates I_[x,y,z] -> K_[y,z,x]
Expand All @@ -48,7 +48,7 @@ namespace ApproxMVBB
else
{
// Make new y-Axis the z-Axis
// R_NK = Rotate around 90∞ around -X, and 90∞ around -Y (always in K frame)
// R_NK = Rotate around 90∞ around -X, and 90∞ around -Y (always in `K` coordinate system)
// )
// A_IN = A_IK * A_KN = R_KI * R_NK
m_q_KI = m_q_KI * Quaternion(0.5, -0.5, -0.5, -0.5);
Expand Down
20 changes: 20 additions & 0 deletions src/ApproxMVBB/ProjectedPointSet.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ========================================================================================
// ApproxMVBB
// Copyright (C) 2014 by Gabriel Nützi <nuetzig (at) imes (d0t) mavt (d0t) ethz
// (døt) ch>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// ========================================================================================
#ifndef ApproxMVBB_ProjectedPointSet_cpp
#define ApproxMVBB_ProjectedPointSet_cpp

#include "ApproxMVBB/ProjectedPointSet.hpp"

namespace ApproxMVBB
{
ProjectedPointSet::ProjectedPointSet() = default;
ProjectedPointSet::~ProjectedPointSet() = default;
} // namespace ApproxMVBB
#endif
4 changes: 2 additions & 2 deletions tests/include/ComputeApproxMVBBTests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ namespace ApproxMVBB

{
// generate points
auto t = getPointsFromFile2D("./PointsSimulation2DRectFail.txt");
auto t = pf::getPointsFromFile2D("./PointsSimulation2DRectFail.txt");
ApproxMVBB::Matrix2Dyn v(2, t.size());
for(unsigned int i = 0; i < t.size(); ++i)
{
Expand Down Expand Up @@ -419,7 +419,7 @@ namespace ApproxMVBB

{
// generate points
auto v = getPointsFromFile2D("./PointsSimulation2DRectFail.txt");
auto v = pf::getPointsFromFile2D("./PointsSimulation2DRectFail.txt");
ApproxMVBB::Matrix2Dyn t(2, v.size());
for(unsigned int i = 0; i < v.size(); ++i)
{
Expand Down
7 changes: 5 additions & 2 deletions tests/include/TestFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@

#define MY_TEST(name1, name2) TEST(name1, name2)
#define MY_TEST_RANDOM_STUFF(name1, name2) \
std::string testName = #name1 "-" #name2; \
auto seed = hashString(#name2); \
using namespace ApproxMVBB; \
namespace pf = ApproxMVBB::PointFunctions; \
namespace tf = ApproxMVBB::TestFunctions; \
std::string testName = #name1 "-" #name2; \
auto seed = TestFunctions::hashString(#name2); \
std::cout << "Seed for this test: " << seed << std::endl; \
ApproxMVBB::RandomGenerators::DefaultRandomGen rng(seed); \
ApproxMVBB::RandomGenerators::DefaultUniformRealDistribution<PREC> uni(0.0, 1.0); \
Expand Down
Loading

0 comments on commit 9e73449

Please sign in to comment.