Commit ba16e6bd authored by Mathias Goldau's avatar Mathias Goldau

[REMOVED] wmath namespace

parent 42a6c3b2
......@@ -296,6 +296,6 @@ inline const typename WBoundingBoxImpl< VT >::vec_type& WBoundingBoxImpl< VT >::
return osg::BoundingBoxImpl< VT >::_max;
}
typedef WBoundingBoxImpl< wmath::WVector3D > WBoundingBox;
typedef WBoundingBoxImpl< WVector3D > WBoundingBox;
#endif // WBOUNDINGBOX_H
......@@ -98,9 +98,9 @@ namespace WPVBaseTypes
typedef std::string PV_STRING; //!< base type used for every WPVString
typedef boost::filesystem::path PV_PATH; //!< base type used for every WPVFilename
typedef WItemSelector PV_SELECTION; //!< base type used for every WPVSelection
typedef wmath::WPosition PV_POSITION; //!< base type used for every WPVPosition
typedef WPosition PV_POSITION; //!< base type used for every WPVPosition
typedef WColor PV_COLOR; //!< base type used for every WPVColor
typedef wmath::WMatrix4x4 PV_MATRIX4X4; //!< base type used for every WPVMatrix4X4
typedef WMatrix4x4 PV_MATRIX4X4; //!< base type used for every WPVMatrix4X4
/**
* Enum denoting the possible trigger states. It is used for trigger properties.
......@@ -543,7 +543,7 @@ namespace PROPERTY_TYPE_HELPER
*/
WPVBaseTypes::PV_MATRIX4X4 create( const WPVBaseTypes::PV_MATRIX4X4& /*old*/, const std::string str )
{
return wmath::fromString( str );
return fromString( str );
}
/**
......@@ -555,7 +555,7 @@ namespace PROPERTY_TYPE_HELPER
*/
std::string asString( const WPVBaseTypes::PV_MATRIX4X4& v )
{
return wmath::toString( v );
return toString( v );
}
};
}
......
......@@ -85,13 +85,13 @@ namespace
}
}
WFiber::WFiber( const std::vector< wmath::WPosition > &points )
: wmath::WLine( points )
WFiber::WFiber( const std::vector< WPosition > &points )
: WLine( points )
{
}
WFiber::WFiber()
: wmath::WLine()
: WLine()
{
}
......
......@@ -31,15 +31,12 @@
#include "../math/WPosition.h"
#include "../WExportCommon.h"
// we need this to find the WFiberTest class which is not inside wmath namespace
// Additionally I found no way to put the WFiberTest class into wmath and CXXTest
// finds it by it self. Hence this is the only solution that might work
class WFiberTest;
/**
* Represents a neural pathway.
*/
class OWCOMMON_EXPORT WFiber : public wmath::WLine
class OWCOMMON_EXPORT WFiber : public WLine
{
friend class WFiberTest;
public:
......@@ -48,7 +45,7 @@ public:
*
* \param points Reference to the points which belong to this fiber
*/
explicit WFiber( const std::vector< wmath::WPosition > &points );
explicit WFiber( const std::vector< WPosition > &points );
/**
* Creates an empty fiber.
......
......@@ -45,7 +45,6 @@ public:
*/
void testEqualityOperator( void )
{
using wmath::WPosition;
WFiber fib1;
WFiber fib2;
fib1.push_back( WPosition( 1.2, 3.4, 5.6 ) );
......@@ -62,11 +61,11 @@ public:
void testDLTisSymmetric( void )
{
WFiber q;
q.push_back( wmath::WPosition( 0, 1, 0 ) );
q.push_back( wmath::WPosition( 0, 0, 0 ) );
q.push_back( WPosition( 0, 1, 0 ) );
q.push_back( WPosition( 0, 0, 0 ) );
WFiber r;
r.push_back( wmath::WPosition( 1, 1, 0 ) );
r.push_back( wmath::WPosition( 2, 2, 0 ) );
r.push_back( WPosition( 1, 1, 0 ) );
r.push_back( WPosition( 2, 2, 0 ) );
TS_ASSERT_EQUALS( WFiber::distDLT( 1.0, q, r ), std::sqrt( 5.0 ) / 2.0 );
TS_ASSERT_EQUALS( WFiber::distDLT( 1.0, r, q ), std::sqrt( 5.0 ) / 2.0 );
......@@ -79,11 +78,11 @@ public:
void testDSTisSymmetric( void )
{
WFiber q;
q.push_back( wmath::WPosition( 0, 1, 0 ) );
q.push_back( wmath::WPosition( 0, 0, 0 ) );
q.push_back( WPosition( 0, 1, 0 ) );
q.push_back( WPosition( 0, 0, 0 ) );
WFiber r;
r.push_back( wmath::WPosition( 1, 1, 0 ) );
r.push_back( wmath::WPosition( 2, 2, 0 ) );
r.push_back( WPosition( 1, 1, 0 ) );
r.push_back( WPosition( 2, 2, 0 ) );
TS_ASSERT_EQUALS( WFiber::distDST( 1.0, q, r ), std::sqrt( 2.0 ) / 2.0 );
TS_ASSERT_EQUALS( WFiber::distDST( 1.0, r, q ), std::sqrt( 2.0 ) / 2.0 );
......@@ -96,11 +95,11 @@ public:
void testDTMeasure( void )
{
WFiber q;
q.push_back( wmath::WPosition( 0, 1, 0 ) );
q.push_back( wmath::WPosition( 0, 0, 0 ) );
q.push_back( WPosition( 0, 1, 0 ) );
q.push_back( WPosition( 0, 0, 0 ) );
WFiber r;
r.push_back( wmath::WPosition( 1, 1, 0 ) );
r.push_back( wmath::WPosition( 2, 2, 0 ) );
r.push_back( WPosition( 1, 1, 0 ) );
r.push_back( WPosition( 2, 2, 0 ) );
TS_ASSERT_EQUALS( WFiber::distDST( 1.0, q, r ), std::sqrt( 2.0 ) / 2.0 );
TS_ASSERT_EQUALS( WFiber::distDLT( 1.0, q, r ), std::sqrt( 5.0 ) / 2.0 );
......
......@@ -27,8 +27,6 @@
#include <string>
namespace wmath
{
/**
* Implements compile-time calculation of binomial coefficients.
*
......@@ -158,6 +156,4 @@ struct WPower< 0, exponent >
};
};
} // namespace wmath
#endif // WCOMPILETIMEFUNCTIONS_H
......@@ -27,7 +27,7 @@
#include "WGeometryFunctions.h"
void wmath::tesselateIcosahedron( std::vector< WVector3D >* vertices, std::vector< unsigned int >* triangles, unsigned int level )
void tesselateIcosahedron( std::vector< WVector3D >* vertices, std::vector< unsigned int >* triangles, unsigned int level )
{
WAssert( vertices, "Missing input vector." );
WAssert( triangles, "Missing input vector." );
......
......@@ -25,15 +25,13 @@
#ifndef WGEOMETRYFUNCTIONS_H
#define WGEOMETRYFUNCTIONS_H
#include <utility>
#include <map>
#include <utility>
#include <vector>
#include "WVector3D.h"
#include "../WAssert.h"
#include "WVector3D.h"
namespace wmath
{
namespace utility
{
/**
......@@ -91,6 +89,4 @@ namespace utility
*/
void OWCOMMON_EXPORT tesselateIcosahedron( std::vector< WVector3D >* vertices, std::vector< unsigned int >* triangles, unsigned int level );
} // namespace wmath
#endif // WGEOMETRYFUNCTIONS_H
......@@ -37,19 +37,17 @@
#include "WPolynomialEquationSolvers.h"
#include "WPosition.h"
namespace wmath
{
WLine::WLine( const std::vector< WPosition > &points )
: WMixinVector< wmath::WPosition >( points )
: WMixinVector< WPosition >( points )
{
}
WLine::WLine()
: WMixinVector< wmath::WPosition >()
: WMixinVector< WPosition >()
{
}
const wmath::WPosition& midPoint( const wmath::WLine& line )
const WPosition& midPoint( const WLine& line )
{
if( line.empty() )
{
......@@ -63,7 +61,7 @@ void WLine::reverseOrder()
std::reverse( begin(), end() );
}
double pathLength( const wmath::WLine& line )
double pathLength( const WLine& line )
{
double length = 0;
// incase of size() <= 1 the for loop will not run!
......@@ -80,7 +78,7 @@ void WLine::resampleByNumberOfPoints( size_t numPoints )
newLine.reserve( numPoints );
if( size() != numPoints && size() > 1 && numPoints > 0 )
{
const double pathL = wmath::pathLength( *this );
const double pathL = pathLength( *this );
double newSegmentLength = pathL / ( numPoints - 1 );
const double delta = newSegmentLength * 1.0e-10; // 1.0e-10 which represents the precision is choosen by intuition
double remainingLength = 0.0;
......@@ -115,7 +113,7 @@ void WLine::resampleByNumberOfPoints( size_t numPoints )
}
if( size() != numPoints )
{
this->WMixinVector< wmath::WPosition >::operator=( newLine );
this->WMixinVector< WPosition >::operator=( newLine );
}
// Note if the size() == 0, then the resampled tract is also of length 0
}
......@@ -139,7 +137,7 @@ void WLine::removeAdjacentDuplicates()
newLine.push_back( *cit );
}
}
this->WMixinVector< wmath::WPosition >::operator=( newLine );
this->WMixinVector< WPosition >::operator=( newLine );
}
void WLine::resampleBySegmentLength( double newSegmentLength )
......@@ -157,7 +155,7 @@ void WLine::resampleBySegmentLength( double newSegmentLength )
{
if( ( newLine.back() - ( *this )[i] ).norm() > newSegmentLength )
{
const wmath::WVector3D& pred = ( *this )[i - 1];
const WVector3D& pred = ( *this )[i - 1];
if( pred == newLine.back() )
{
// Then there is no triangle and the old Segment Length is bigger as the new segment
......@@ -183,11 +181,11 @@ void WLine::resampleBySegmentLength( double newSegmentLength )
( pred[2] - newLine.back()[2] ) * ( pred[2] - newLine.back()[2] ) - newSegmentLength * newSegmentLength;
typedef std::pair< std::complex< double >, std::complex< double > > ComplexPair;
ComplexPair solution = wmath::solveRealQuadraticEquation( alpha, beta, gamma );
ComplexPair solution = solveRealQuadraticEquation( alpha, beta, gamma );
// NOTE: if those asserts fire, then this algo is wrong and produces wrong results, and I've to search to bug!
WAssert( std::imag( solution.first ) == 0.0, "Invalid quadratic equation while computing resamplingBySegmentLength" );
WAssert( std::imag( solution.second ) == 0.0, "Invalid quadratic equation while computing resamplingBySegmentLength" );
wmath::WPosition pointOfIntersection;
WPosition pointOfIntersection;
if( std::real( solution.first ) > 0.0 )
{
pointOfIntersection = pred + std::real( solution.first ) * ( ( *this )[i] - pred );
......@@ -203,13 +201,13 @@ void WLine::resampleBySegmentLength( double newSegmentLength )
}
if( ( newLine.back() - ( *this )[size() - 1] ).norm() > newSegmentLength / 2.0 )
{
wmath::WVector3D direction = ( ( *this )[size() - 1] - newLine.back() ).normalized();
WVector3D direction = ( ( *this )[size() - 1] - newLine.back() ).normalized();
newLine.push_back( newLine.back() + direction * newSegmentLength );
}
this->WMixinVector< wmath::WPosition >::operator=( newLine );
this->WMixinVector< WPosition >::operator=( newLine );
}
int equalsDelta( const wmath::WLine& line, const wmath::WLine& other, double delta )
int equalsDelta( const WLine& line, const WLine& other, double delta )
{
size_t pts = ( std::min )( other.size(), line.size() ); // This ( std::min ) thing compiles also under Win32/Win64
size_t diffPos = 0;
......@@ -232,7 +230,7 @@ int equalsDelta( const wmath::WLine& line, const wmath::WLine& other, double del
return diffPos;
}
double maxSegmentLength( const wmath::WLine& line )
double maxSegmentLength( const WLine& line )
{
double result = 0.0;
if( line.empty() || line.size() == 1 )
......@@ -246,7 +244,7 @@ double maxSegmentLength( const wmath::WLine& line )
return result;
}
WBoundingBox computeBoundingBox( const wmath::WLine& line )
WBoundingBox computeBoundingBox( const WLine& line )
{
WBoundingBox result;
for( WLine::const_iterator cit = line.begin(); cit != line.end(); ++cit )
......@@ -255,5 +253,3 @@ WBoundingBox computeBoundingBox( const wmath::WLine& line )
}
return result;
}
} // end of namespace wmath
......@@ -34,124 +34,120 @@
#include "../WMixinVector.h"
#include "WPosition.h"
// we need this to find the WLineTest class which is not inside wmath namespace
// forward declarations
class WLineTest;
namespace wmath
/**
* A line is an ordered sequence of WPositions.
*/
class OWCOMMON_EXPORT WLine : public WMixinVector< WPosition >
{
public:
/**
* A line is an ordered sequence of WPositions.
*/
class OWCOMMON_EXPORT WLine : public WMixinVector< WPosition >
{
public:
/**
* Generates a new line out of a sequence of points.
*
* \param points Point sequence
*/
explicit WLine( const std::vector< WPosition > &points );
/**
* Creates an empty line.
*/
WLine();
/**
* Resample this line so it has a number of given points afterwards.
* \warning This changes your line!
*
* \param numPoints Number of sampling points.
*/
void resampleByNumberOfPoints( size_t numPoints );
/**
*
*
* \warning This may elongate your line at max. by the newSegmentLength
*
* \param newSegementLength
*/
void resampleBySegmentLength( double newSegementLength );
/**
* Reverses the order of the points. (mirroring)
*/
void reverseOrder();
/**
* Collapse samplepoints which are equal and neighboured.
*/
void removeAdjacentDuplicates();
};
// Some convinience functions as non-member non-friend functions
/**
* Computes a AABB (axis aligned bounding box) for all positions inside this line.
*
* \param line The line to compute the bounding box for.
* Generates a new line out of a sequence of points.
*
* \return The AABB for this line.
* \param points Point sequence
*/
OWCOMMON_EXPORT WBoundingBox computeBoundingBox( const wmath::WLine& line );
explicit WLine( const std::vector< WPosition > &points );
/**
* Computes the length of a line in terms of accumulated segment lengths.
*
* \param line The line which used for computations
*
* \return Sum of all line segment lengths
* Creates an empty line.
*/
OWCOMMON_EXPORT double pathLength( const wmath::WLine& line );
WLine();
/**
* Returns the point in the middle of a line. In case of an even sized
* line the mid point is the same as if there were only size()-1 many
* elements present.
*
* \param line The line to compute the mid point for.
* Resample this line so it has a number of given points afterwards.
* \warning This changes your line!
*
* \throws WOutOfBounds In case its called on an empty line
*
* \return Const reference to the midpoint element.
* \param numPoints Number of sampling points.
*/
OWCOMMON_EXPORT const wmath::WPosition& midPoint( const wmath::WLine& line );
void resampleByNumberOfPoints( size_t numPoints );
/**
* Compares two lines with each other point wise upto a given delta.
*
* \param line The first line
* \param other The other line
* \param delta Specifying the environment upto this two points are considered to be the same
*
* \return -1 in case of the two fibers are considered equal, otherwise the first position on which they differ is returned.
* \warning This may elongate your line at max. by the newSegmentLength
*
* \param newSegementLength
*/
OWCOMMON_EXPORT int equalsDelta( const wmath::WLine& line, const wmath::WLine& other, double delta );
void resampleBySegmentLength( double newSegementLength );
/**
* Compute the maximal segment length of all segements of a line. If there are no segements meaning
* zero or one point, zero is returned.
*
* \param line The line used for computation of the max segment length
*
* \return Max segement length or zero if there aren't any.
* Reverses the order of the points. (mirroring)
*/
OWCOMMON_EXPORT double maxSegmentLength( const wmath::WLine& line );
void reverseOrder();
/**
* Boolean predicate indicating that the first line has more points then
* the second one.
*
* \param first First line
* \param second Second line
* \return True if the first line has more points than the second
* Collapse samplepoints which are equal and neighboured.
*/
bool hasMorePointsThen( const WLine& first, const WLine& second );
} // end of namespace wmath
inline bool wmath::hasMorePointsThen( const WLine& first, const WLine& second )
void removeAdjacentDuplicates();
};
// Some convinience functions as non-member non-friend functions
/**
* Computes a AABB (axis aligned bounding box) for all positions inside this line.
*
* \param line The line to compute the bounding box for.
*
* \return The AABB for this line.
*/
OWCOMMON_EXPORT WBoundingBox computeBoundingBox( const WLine& line );
/**
* Computes the length of a line in terms of accumulated segment lengths.
*
* \param line The line which used for computations
*
* \return Sum of all line segment lengths
*/
OWCOMMON_EXPORT double pathLength( const WLine& line );
/**
* Returns the point in the middle of a line. In case of an even sized
* line the mid point is the same as if there were only size()-1 many
* elements present.
*
* \param line The line to compute the mid point for.
*
* \throws WOutOfBounds In case its called on an empty line
*
* \return Const reference to the midpoint element.
*/
OWCOMMON_EXPORT const WPosition& midPoint( const WLine& line );
/**
* Compares two lines with each other point wise upto a given delta.
*
* \param line The first line
* \param other The other line
* \param delta Specifying the environment upto this two points are considered to be the same
*
* \return -1 in case of the two fibers are considered equal, otherwise the first position on which they differ is returned.
*/
OWCOMMON_EXPORT int equalsDelta( const WLine& line, const WLine& other, double delta );
/**
* Compute the maximal segment length of all segements of a line. If there are no segements meaning
* zero or one point, zero is returned.
*
* \param line The line used for computation of the max segment length
*
* \return Max segement length or zero if there aren't any.
*/
OWCOMMON_EXPORT double maxSegmentLength( const WLine& line );
/**
* Boolean predicate indicating that the first line has more points then
* the second one.
*
* \param first First line
* \param second Second line
* \return True if the first line has more points than the second
*/
bool hasMorePointsThen( const WLine& first, const WLine& second );
inline bool hasMorePointsThen( const WLine& first, const WLine& second )
{
return first.size() > second.size();
}
......
......@@ -24,20 +24,17 @@
#include <vector>
#include "../WAssert.h"
#include "WLinearAlgebraFunctions.h"
#ifdef OW_USE_OSSIM
#include "WOSSIMHelper.h"
#endif
#include "WMatrix.h"
#include "WMatrix4x4.h"
#include "WValue.h"
#include "WVector3D.h"
#include "../WAssert.h"
namespace wmath
{
#ifdef OW_USE_OSSIM
#include "WOSSIMHelper.h"
#endif
WVector3D multMatrixWithVector3D( WMatrix<double> mat, WVector3D vec )
{