Commit 8c1bc52f authored by Stephen M. Webb's avatar Stephen M. Webb

Imported Upstream version 0.3.12

parent 08380956
2012-01-18 Al Riddoch <alriddoch@googlemail.com>
* Release 0.3.12, interface version 6
2012-01-18 Al Riddoch <alriddoch@googlemail.com>
* Fix a number of portability bugs. Make a bunch of performance
improvements, mostly be avoiding converting between double and float.
Switch to using standard C++ library for math functions, as the way
templates work makes getting the right float type way more efficient.
Fix some bad namespacing which broke on some compilers.
2011-02-12 Al Riddoch <alriddoch@googlemail.com>
* Release 0.3.11, interface version 5
......
......@@ -149,6 +149,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
......@@ -172,6 +173,7 @@ LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
......@@ -202,6 +204,7 @@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
......
2012-01-18 Al Riddoch <alriddoch@googlemail.com>
* wfmath 0.3.12 released.
2011-02-12 Al Riddoch <alriddoch@googlemail.com>
* wfmath 0.3.11 released.
......
In const.cpp there are weird "using namespace" crap, and calls to library
functions not in std::. Ron says this is because of broken MSVC, which we
should be able to work around by now.
Re-write operators so that for a given operator O, operatorO is implemented
using operatorO= rather than the other way around which is inefficient.
......
This diff is collapsed.
......@@ -176,6 +176,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
......@@ -199,6 +200,7 @@ LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
......@@ -229,6 +231,7 @@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
......
......@@ -3,9 +3,6 @@
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the `fabsf' function. */
#undef HAVE_FABSF
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
......
This diff is collapsed.
dnl Autoconf setup
AC_INIT([wfmath], [0.3.11], [alriddoch@googlemail.com])
AC_INIT([wfmath], [0.3.12], [alriddoch@googlemail.com])
AC_CONFIG_SRCDIR([wfmath/const.cpp])
AC_CONFIG_HEADERS([config.h])
......@@ -13,7 +13,7 @@ dnl Automake setup
AM_INIT_AUTOMAKE([nostdinc dist-bzip2 check-news color-tests parallel-tests])
dnl versioning info for libtool
WFMATH_CURRENT=5
WFMATH_CURRENT=6
WFMATH_REVISION=0
WFMATH_AGE=0
WFMATH_VERSION_INFO=$WFMATH_CURRENT:$WFMATH_REVISION:$WFMATH_AGE
......@@ -45,11 +45,27 @@ SYSTEM_LIBS="-lm"
WFMATH_LIB_SUFFIX="-0.3"
WFMATH_LIBS="-lwfmath$WFMATH_LIB_SUFFIX"
AC_MSG_NOTICE([Ignore the Atlas checks, they're just used for building test code])
AC_MSG_NOTICE([Ignore the Atlas checks, they are just used for building test code])
AC_LANG(C++)
AC_CHECK_FUNCS([fabsf])
AC_MSG_CHECKING([whether std::fabs works])
AC_COMPILE_IFELSE(
[
AC_LANG_PROGRAM(
[[
#include <cmath>
]],
[[
std::fabs(0.5f);
]])
],
[
AC_MSG_RESULT([yes])
],
[
AC_MSG_RESULT([no])
])
PKG_PROG_PKG_CONFIG
......
......@@ -69,6 +69,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
......@@ -92,6 +93,7 @@ LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
......@@ -122,6 +124,7 @@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
......
This diff is collapsed.
%define name wfmath
%define version 0.3.11
%define version 0.3.12
%define release 1
%define libsuffix -0.3
......
......@@ -2,6 +2,8 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)
EXTRA_DIST = bc_sloppy_mag_3
RECHECK_LOGS =
headerdir = $(includedir)/wfmath-0.3/wfmath
header_HEADERS = error.h const.h int_to_string.h \
probability.h timestamp.h \
......
......@@ -239,7 +239,6 @@ elif test -f "$$f"; then dir=; \
else dir="$(srcdir)/"; fi; \
tst=$$dir$$f; log='$@'; __SAVED_TERM=$$TERM; \
$(TESTS_ENVIRONMENT)
RECHECK_LOGS = $(TEST_LOGS)
AM_RECURSIVE_TARGETS = check check-html recheck recheck-html
TEST_SUITE_LOG = test-suite.log
TEST_SUITE_HTML = $(TEST_SUITE_LOG:.log=.html)
......@@ -273,6 +272,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
......@@ -296,6 +296,7 @@ LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
......@@ -326,6 +327,7 @@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
......@@ -376,6 +378,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)
EXTRA_DIST = bc_sloppy_mag_3
RECHECK_LOGS =
headerdir = $(includedir)/wfmath-0.3/wfmath
header_HEADERS = error.h const.h int_to_string.h \
probability.h timestamp.h \
......
......@@ -140,13 +140,13 @@ protected:
};
inline MTRand::MTRand( const uint32& oneSeed )
inline MTRand::MTRand( const uint32& oneSeed ) : pNext(0), left(0)
{ seed(oneSeed); }
inline MTRand::MTRand( uint32 *const bigSeed, const uint32 seedLength )
inline MTRand::MTRand( uint32 *const bigSeed, const uint32 seedLength ) : pNext(0), left(0)
{ seed(bigSeed,seedLength); }
inline MTRand::MTRand()
inline MTRand::MTRand() : pNext(0), left(0)
{ seed(); }
inline double MTRand::rand()
......
......@@ -54,24 +54,8 @@ typedef Atlas::Message::MapType _AtlasMapType;
inline bool _isNum(const _AtlasMessageType& a) {return a.isNum();}
inline _AtlasFloatType _asNum(const _AtlasMessageType& a) {return a.asNum();}
#elif defined(ATLAS_MESSAGE_OBJECT_H)
struct _AtlasBadParse : public Atlas::Message::WrongTypeException,
virtual public std::exception
{
virtual ~_AtlasBadParse() throw() {}
};
typedef Atlas::Message::Object _AtlasMessageType;
typedef Atlas::Message::Object::FloatType _AtlasFloatType;
typedef Atlas::Message::Object::ListType _AtlasListType;
typedef Atlas::Message::Object::MapType _AtlasMapType;
inline bool _isNum(const _AtlasMessageType& a) {return a.IsNum();}
inline _AtlasMessageType::FloatType _asNum(const _AtlasMessageType& a) {return a.AsNum();}
#else
#error "You must include Atlas/Message/Element.h or Atlas/Message/Object.h before wfmath/atlasconv.h"
#error "You must include Atlas/Message/Element.h before wfmath/atlasconv.h"
#endif
class AtlasInType
......@@ -81,13 +65,8 @@ class AtlasInType
// allow nice conversions when necessary
template<class C> AtlasInType(C c) : m_obj(c), m_val(m_obj) {}
operator const _AtlasMessageType&() const {return m_val;}
#ifdef ATLAS_MESSAGE_ELEMENT_H
bool IsList() const {return m_val.isList();}
const _AtlasListType& AsList() const {return m_val.asList();}
#else // ATLAS_MESSAGE_OBJECT_H
bool IsList() const {return m_val.IsList();}
const _AtlasListType& AsList() const {return m_val.AsList();}
#endif
private:
_AtlasMessageType m_obj;
const _AtlasMessageType& m_val;
......@@ -128,20 +107,20 @@ inline void _ArrayFromAtlas(CoordType* array, unsigned len, const AtlasInType& a
array[i] = _asNum(list[i]);
}
template<const int dim>
template<int dim>
inline Vector<dim>::Vector(const AtlasInType& a)
{
fromAtlas(a);
}
template<const int dim>
template<int dim>
inline void Vector<dim>::fromAtlas(const AtlasInType& a)
{
_ArrayFromAtlas(m_elem, dim, a);
m_valid = true;
}
template<const int dim>
template<int dim>
inline AtlasOutType Vector<dim>::toAtlas() const
{
return _ArrayToAtlas(m_elem, dim);
......@@ -164,7 +143,7 @@ inline void Quaternion::fromAtlas(const AtlasInType& a)
m_w = _asNum(list[3]);
CoordType norm = sqrt(m_w * m_w + m_vec.sqrMag());
CoordType norm = std::sqrt(m_w * m_w + m_vec.sqrMag());
if (norm <= WFMATH_EPSILON) {
m_valid = false;
......@@ -191,32 +170,32 @@ inline AtlasOutType Quaternion::toAtlas() const
return a;
}
template<const int dim>
template<int dim>
inline Point<dim>::Point(const AtlasInType& a)
{
fromAtlas(a);
}
template<const int dim>
template<int dim>
inline void Point<dim>::fromAtlas(const AtlasInType& a)
{
_ArrayFromAtlas(m_elem, dim, a);
m_valid = true;
}
template<const int dim>
template<int dim>
inline AtlasOutType Point<dim>::toAtlas() const
{
return _ArrayToAtlas(m_elem, dim);
}
template<const int dim>
template<int dim>
inline AxisBox<dim>::AxisBox(const AtlasInType& a)
{
fromAtlas(a);
}
template<const int dim>
template<int dim>
inline void AxisBox<dim>::fromAtlas(const AtlasInType& a)
{
if(!a.IsList())
......@@ -250,7 +229,7 @@ inline void AxisBox<dim>::fromAtlas(const AtlasInType& a)
}
}
template<const int dim>
template<int dim>
inline AtlasOutType AxisBox<dim>::toAtlas() const
{
int i;
......@@ -273,7 +252,7 @@ inline AtlasOutType AxisBox<dim>::toAtlas() const
return a;
}
template<const int dim>
template<int dim>
inline void Ball<dim>::fromAtlas(const AtlasInType& a)
{
const _AtlasMessageType& message(a);
......@@ -297,7 +276,7 @@ inline void Ball<dim>::fromAtlas(const AtlasInType& a)
}
}
template<const int dim>
template<int dim>
inline AtlasOutType Ball<dim>::toAtlas() const
{
Atlas::Message::MapType map;
......@@ -306,13 +285,36 @@ inline AtlasOutType Ball<dim>::toAtlas() const
return map;
}
template<const int dim>
template<int dim>
inline Ball<dim>::Ball(const AtlasInType& a) : m_center(Point<dim>::ZERO()),
m_radius(0)
{
fromAtlas(a);
}
template<template <int> class ShapeT, int dim>
inline void _CornersFromAtlas(ShapeT<dim> & shape,
const _AtlasMessageType& message)
{
if (message.isList()) {
const Atlas::Message::ListType& pointsData(message.asList());
for (size_t p = 0; p < pointsData.size(); ++p) {
if (!pointsData[p].isList()) {
continue;
}
const Atlas::Message::ListType& point(pointsData[p].asList());
if ((point.size() < dim) || !point[0].isNum() || !point[1].isNum()) {
continue;
}
WFMath::Point<dim> wpt(point[0].asNum(), point[1].asNum());
shape.addCorner(shape.numCorners(), wpt);
}
}
}
inline void Polygon<2>::fromAtlas(const AtlasInType& a)
{
const _AtlasMessageType& message(a);
......@@ -320,25 +322,16 @@ inline void Polygon<2>::fromAtlas(const AtlasInType& a)
const Atlas::Message::MapType& shapeElement(message.asMap());
Atlas::Message::MapType::const_iterator it = shapeElement.find("points");
if ((it != shapeElement.end()) && it->second.isList()) {
const Atlas::Message::ListType& pointsData(it->second.asList());
for (size_t p = 0; p < pointsData.size(); ++p) {
if (!pointsData[p].isList()) {
continue;
}
const Atlas::Message::ListType& point(pointsData[p].asList());
if ((point.size() < 2) || !point[0].isNum() || !point[1].isNum()) {
continue;
}
WFMath::Point<2> wpt(point[0].asNum(), point[1].asNum());
addCorner(numCorners(), wpt);
}
_CornersFromAtlas(*this, it->second);
if (numCorners() > 2) {
return;
}
}
} else if (message.isList()) {
_CornersFromAtlas(*this, message);
if (numCorners() > 2) {
return;
}
}
throw _AtlasBadParse();
}
......@@ -356,7 +349,7 @@ inline AtlasOutType Polygon<2>::toAtlas() const
}
template<const int dim>
template<int dim>
inline void RotBox<dim>::fromAtlas(const AtlasInType& a)
{
const _AtlasMessageType& message(a);
......@@ -384,7 +377,7 @@ inline void RotBox<dim>::fromAtlas(const AtlasInType& a)
throw _AtlasBadParse();
}
template<const int dim>
template<int dim>
inline AtlasOutType RotBox<dim>::toAtlas() const
{
Atlas::Message::MapType map;
......@@ -394,7 +387,7 @@ inline AtlasOutType RotBox<dim>::toAtlas() const
return map;
}
template<const int dim>
template<int dim>
inline RotBox<dim>::RotBox(const AtlasInType& a) {
fromAtlas(a);
}
......
......@@ -48,7 +48,4 @@ template AxisBox<2> BoundingBox<2, std::vector>(const std::vector<AxisBox<2>, st
template AxisBox<2> BoundingBox<2, std::vector>(const std::vector<Point<2>, std::allocator<Point<2> > >&);
template AxisBox<2> Point<2>::boundingBox() const;
template AxisBox<3> Point<3>::boundingBox() const;
}
......@@ -35,39 +35,38 @@
namespace WFMath {
template<const int dim>
template<int dim>
bool Intersection(const AxisBox<dim>& a1, const AxisBox<dim>& a2, AxisBox<dim>& out);
template<const int dim>
template<int dim>
AxisBox<dim> Union(const AxisBox<dim>& a1, const AxisBox<dim>& a2);
template<const int dim>
template<int dim>
std::ostream& operator<<(std::ostream& os, const AxisBox<dim>& m);
template<const int dim>
template<int dim>
std::istream& operator>>(std::istream& is, AxisBox<dim>& m);
#ifndef WFMATH_NO_TEMPLATES_AS_TEMPLATE_PARAMETERS
/// Get the axis-aligned bounding box for a set of boxes
template<const int dim, template<class, class> class container>
template<int dim, template<class, class> class container>
AxisBox<dim> BoundingBox(const container<AxisBox<dim>, std::allocator<AxisBox<dim> > >& c);
/// Get the axis-aligned bounding box for a set of points
template<const int dim, template<class, class> class container>
template<int dim, template<class, class> class container>
AxisBox<dim> BoundingBox(const container<Point<dim>, std::allocator<Point<dim> > >& c);
#endif
/// A dim dimensional axis-aligned box
/**
* This class implements the full shape interface, as described in
* the fake class Shape, with the exception of the rotation functions.
**/
template<const int dim = 3>
template<int dim = 3>
class AxisBox
{
public:
/// Construct an uninitialized box
AxisBox() {}
AxisBox() : m_low(), m_high() {}
/// Construct a box with opposite corners p1 and p2
AxisBox(const Point<dim>& p1, const Point<dim>& p2, bool ordered = false)
AxisBox(const Point<dim>& p1, const Point<dim>& p2, bool ordered = false) :
m_low(), m_high()
{setCorners(p1, p2, ordered);}
/// Construct a copy of a box
AxisBox(const AxisBox& a) : m_low(a.m_low), m_high(a.m_high) {}
......
......@@ -36,14 +36,14 @@
namespace WFMath {
template<const int dim>
template<int dim>
inline bool AxisBox<dim>::isEqualTo(const AxisBox<dim>& b, double epsilon) const
{
return Equal(m_low, b.m_low, epsilon)
&& Equal(m_high, b.m_high, epsilon);
}
template<const int dim>
template<int dim>
bool Intersection(const AxisBox<dim>& a1, const AxisBox<dim>& a2, AxisBox<dim>& out)
{
for(int i = 0; i < dim; ++i) {
......@@ -59,7 +59,7 @@ bool Intersection(const AxisBox<dim>& a1, const AxisBox<dim>& a2, AxisBox<dim>&
return true;
}
template<const int dim>
template<int dim>
AxisBox<dim> Union(const AxisBox<dim>& a1, const AxisBox<dim>& a2)
{
AxisBox<dim> out;
......@@ -75,7 +75,7 @@ AxisBox<dim> Union(const AxisBox<dim>& a1, const AxisBox<dim>& a2)
return out;
}
template<const int dim>
template<int dim>
AxisBox<dim>& AxisBox<dim>::setCorners(const Point<dim>& p1, const Point<dim>& p2,
bool ordered)
{
......@@ -102,7 +102,7 @@ AxisBox<dim>& AxisBox<dim>::setCorners(const Point<dim>& p1, const Point<dim>& p
return *this;
}
template<const int dim>
template<int dim>
Point<dim> AxisBox<dim>::getCorner(int i) const
{
if(i < 1)
......@@ -120,21 +120,20 @@ Point<dim> AxisBox<dim>::getCorner(int i) const
return out;
}
template<const int dim>
template<int dim>
inline Ball<dim> AxisBox<dim>::boundingSphere() const
{
return Ball<dim>(getCenter(), Distance(m_low, m_high) / 2);
}
template<const int dim>
template<int dim>
inline Ball<dim> AxisBox<dim>::boundingSphereSloppy() const
{
return Ball<dim>(getCenter(), SloppyDistance(m_low, m_high) / 2);
}
#ifndef WFMATH_NO_TEMPLATES_AS_TEMPLATE_PARAMETERS
template<const int dim, template<class, class> class container>
template<int dim, template<class, class> class container>
AxisBox<dim> BoundingBox(const container<AxisBox<dim>, std::allocator<AxisBox<dim> > >& c)
{
// FIXME become friend
......@@ -164,7 +163,7 @@ AxisBox<dim> BoundingBox(const container<AxisBox<dim>, std::allocator<AxisBox<di
return AxisBox<dim>(low, high, true);
}
template<const int dim, template<class, class> class container>
template<int dim, template<class, class> class container>
AxisBox<dim> BoundingBox(const container<Point<dim>, std::allocator<Point<dim> > >& c)
{
typename container<Point<dim>, std::allocator<Point<dim> > >::const_iterator i = c.begin(), end = c.end();
......@@ -189,24 +188,23 @@ AxisBox<dim> BoundingBox(const container<Point<dim>, std::allocator<Point<dim> >
return AxisBox<dim>(low, high, true);
}
#endif
// This is here, instead of defined in the class, to
// avoid include order problems
template<const int dim>
template<int dim>
inline AxisBox<dim> Point<dim>::boundingBox() const
{
return AxisBox<dim>(*this, *this, true);
}
template<const int dim>
template<int dim>
Point<dim> Point<dim>::toParentCoords(const AxisBox<dim>& coords) const
{
return coords.lowCorner() + (*this - Point().setToOrigin());
}
template<const int dim>
template<int dim>
Point<dim> Point<dim>::toLocalCoords(const AxisBox<dim>& coords) const
{
return Point().setToOrigin() + (*this - coords.lowCorner());
......
......@@ -31,20 +31,18 @@
namespace WFMath {
template<const int dim> class Ball;
template<int dim> class Ball;
#ifndef WFMATH_NO_TEMPLATES_AS_TEMPLATE_PARAMETERS
/// get the minimal bounding sphere for a set of points
template<const int dim, template<class, class> class container>
template<int dim, template<class, class> class container>
Ball<dim> BoundingSphere(const container<Point<dim>, std::allocator<Point<dim> > >& c);
/// get a bounding sphere for a set of points
template<const int dim, template<class, class> class container>
template<int dim, template<class, class> class container>
Ball<dim> BoundingSphereSloppy(const container<Point<dim>, std::allocator<Point<dim> > >& c);
#endif
template<const int dim>
template<int dim>
std::ostream& operator<<(std::ostream& os, const Ball<dim>& m);
template<const int dim>
template<int dim>
std::istream& operator>>(std::istream& is, Ball<dim>& m);
/// A dim dimensional ball
......@@ -58,12 +56,12 @@ std::istream& operator>>(std::istream& is, Ball<dim>& m);
* helps that a Ball<n> corresponds to an n-ball, while a Sphere<n>
* would correspond to an (n-1)-sphere.
**/
template<const int dim = 3>
template<int dim = 3>
class Ball
{
public:
/// construct an uninitialized ball
Ball() {}
Ball() : m_center(), m_radius(0.f) {}
/// construct a ball with the given center and radius
Ball(const Point<dim>& center, CoordType radius)
: m_center(center), m_radius(radius) { if (radius < 0) m_center.setValid(false); }
......
......@@ -35,14 +35,14 @@
namespace WFMath {
template<const int dim>
template<int dim>
inline bool Ball<dim>::isEqualTo(const Ball<dim>& b, double epsilon) const
{
return Equal(m_center, b.m_center, epsilon)
&& Equal(m_radius, b.m_radius, epsilon);
}
template<const int dim>
template<int dim>
AxisBox<dim> Ball<dim>::boundingBox() const
{
Point<dim> p_low, p_high;
......@@ -60,8 +60,7 @@ AxisBox<dim> Ball<dim>::boundingBox() const
return AxisBox<dim>(p_low, p_high, true);
}
#ifndef WFMATH_NO_TEMPLATES_AS_TEMPLATE_PARAMETERS
template<const int dim, template<class, class> class container>
template<int dim, template<class, class> class container>
Ball<dim> BoundingSphere(const container<Point<dim>, std::allocator<Point<dim> > >& c)
{
_miniball::Miniball<dim> m;
......@@ -93,10 +92,10 @@ Ball<dim> BoundingSphere(const container<Point<dim>, std::allocator<Point<dim> >
center.setValid(valid);
return Ball<dim>(center, sqrt(m.squared_radius()));
return Ball<dim>(center, std::sqrt(m.squared_radius()));
}
template<const int dim, template<class, class> class container>
template<int dim, template<class, class> class container>
Ball<dim> BoundingSphereSloppy(const container<Point<dim>, std::allocator<Point<dim> > >& c)
{
// This is based on the algorithm given by Jack Ritter
......@@ -169,18 +168,17 @@ Ball<dim> BoundingSphereSloppy(const container<Point<dim>, std::allocator<Point<
return Ball<2>(center, dist);
}
#endif
// These two are here, instead of defined in the class, to
// avoid include order problems
template<const int dim>
template<int dim>
inline Ball<dim> Point<dim>::boundingSphere() const
{
return Ball<dim>(*this, 0);
}
template<const int dim>