Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes to allow compilation in Visual Studio 2015, and get rid of some warnings #99

Merged
merged 3 commits into from
Mar 21, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BVH/BV_fitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace fcl
static const double kIOS_RATIO = 1.5;
static const double invSinA = 2;
static const double invCosA = 2.0 / sqrt(3.0);
static const double sinA = 0.5;
// static const double sinA = 0.5;
static const double cosA = sqrt(3.0) / 2.0;

static inline void axisFromEigen(Vec3f eigenV[3], Matrix3f::U eigenS[3], Vec3f axis[3])
Expand Down
1 change: 1 addition & 0 deletions src/broadphase/interval_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "fcl/broadphase/interval_tree.h"
#include <iostream>
#include <cstdlib>
#include <algorithm>


namespace fcl
Expand Down
17 changes: 9 additions & 8 deletions test/test_fcl_capsule_capsule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
#include "fcl/shape/geometric_shapes.h"
#include "fcl/narrowphase/narrowphase.h"

#include "math.h"

#include <cmath>
using namespace fcl;

BOOST_AUTO_TEST_CASE(distance_capsulecapsule_origin)
Expand All @@ -66,7 +65,7 @@ BOOST_AUTO_TEST_CASE(distance_capsulecapsule_origin)
std::cerr << "applied transformation of two caps: " << transform.getTranslation() << " & " << transform2.getTranslation() << std::endl;
std::cerr << "computed points in caps to caps" << closest_p1 << " & " << closest_p2 << "with dist: " << dist << std::endl;

BOOST_CHECK(fabs(dist - 10.1) < 0.001);
BOOST_CHECK(std::abs(dist - 10.1) < 0.001);
BOOST_CHECK(res);

}
Expand All @@ -92,8 +91,8 @@ BOOST_AUTO_TEST_CASE(distance_capsulecapsule_transformXY)
std::cerr << "applied transformation of two caps: " << transform.getTranslation() << " & " << transform2.getTranslation() << std::endl;
std::cerr << "computed points in caps to caps" << closest_p1 << " & " << closest_p2 << "with dist: " << dist << std::endl;

float expected = sqrt(800) - 10;
BOOST_CHECK(fabs(expected-dist) < 0.01);
FCL_REAL expected = std::sqrt(FCL_REAL(800)) - 10;
BOOST_CHECK(std::abs(expected-dist) < 0.01);
BOOST_CHECK(res);

}
Expand All @@ -118,14 +117,15 @@ BOOST_AUTO_TEST_CASE(distance_capsulecapsule_transformZ)
std::cerr << "applied transformation of two caps: " << transform.getTranslation() << " & " << transform2.getTranslation() << std::endl;
std::cerr << "computed points in caps to caps" << closest_p1 << " & " << closest_p2 << "with dist: " << dist << std::endl;

BOOST_CHECK(fabs(dist - 0.1) < 0.001);
BOOST_CHECK(std::abs(dist - 0.1) < 0.001);
BOOST_CHECK(res);

}


BOOST_AUTO_TEST_CASE(distance_capsulecapsule_transformZ2)
{
const FCL_REAL Pi = std::acos(FCL_REAL(-1.0));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer either using boost::math::constants::pi or defining M_PI if not defined.
{{{
#ifndef M_PI
#define M_PI 3.1415926535....
#endif
}}}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to fix what appeared to be incorrect use of floating point type. Using macros for constants means they will be untyped and might not convert properly to FCL_REAL. I took a look at boost::pi and can't figure out what type it is! I don't think it is a good idea to have the digits of pi included here -- there must be a better way! What would you suggest as the proper way to get a "pi" of type FCL_REAL?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see -- it's a template function. I'll use it.


GJKSolver_indep solver;
Capsule s1(5, 10);
Expand All @@ -137,7 +137,8 @@ BOOST_AUTO_TEST_CASE(distance_capsulecapsule_transformZ2)
Transform3f transform2;
transform2 = Transform3f(Vec3f(0,0,25.1));
Matrix3f rot2;
rot2.setEulerZYX(0,M_PI_2,0);

rot2.setEulerZYX(0,Pi/2,0);
transform2.setRotation(rot2);

bool res;
Expand All @@ -148,7 +149,7 @@ BOOST_AUTO_TEST_CASE(distance_capsulecapsule_transformZ2)
std::cerr << "applied transformation of two caps: " << transform.getRotation() << " & " << transform2.getRotation() << std::endl;
std::cerr << "computed points in caps to caps" << closest_p1 << " & " << closest_p2 << "with dist: " << dist << std::endl;

BOOST_CHECK(fabs(dist - 5.1) < 0.001);
BOOST_CHECK(std::abs(dist - 5.1) < 0.001);
BOOST_CHECK(res);

}
2 changes: 1 addition & 1 deletion test/test_fcl_collision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ BOOST_AUTO_TEST_CASE(OBB_shape_test)
computeBV(ellipsoid, transforms[i], obb2);

bool overlap_obb = obb1.overlap(obb2);
bool overlap_ellipsoid = solver.shapeIntersect(box1, box1_tf, ellipsoid, transforms[i], NULL, NULL, NULL);
bool overlap_ellipsoid = solver.shapeIntersect(box1, box1_tf, ellipsoid, transforms[i], NULL);
BOOST_CHECK(overlap_obb >= overlap_ellipsoid);
}

Expand Down