Commit 0909ea9f authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - removed all old WVector3D and WMatrix4x4. Only 3 compatibility...

[CHANGE] - removed all old WVector3D and WMatrix4x4. Only 3 compatibility functions needed until now. They will be removed next (since they are not implemented).
parent 7b35e575
......@@ -30,7 +30,7 @@
#include <osg/BoundingBox>
#include "exceptions/WInvalidBoundingBox.h"
#include "math/WVector3D.h"
#include "math/linearAlgebra/WLinearAlgebra.h"
/**
* Represents a \e axis \e parallel bounding box and provides some useful operations with them.
......@@ -296,6 +296,6 @@ inline const typename WBoundingBoxImpl< VT >::vec_type& WBoundingBoxImpl< VT >::
return osg::BoundingBoxImpl< VT >::_max;
}
typedef WBoundingBoxImpl< WVector3D > WBoundingBox;
typedef WBoundingBoxImpl< osg::Vec3 > WBoundingBox;
#endif // WBOUNDINGBOX_H
......@@ -39,8 +39,9 @@
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
#include "math/WPosition.h"
#include "math/linearAlgebra/WLinearAlgebra.h"
#include "math/linearAlgebra/WMatrixFixed.h"
#include "math/linearAlgebra/WVectorFixed.h"
#include "WItemSelector.h"
#include "WColor.h"
#include "WAssert.h"
......@@ -104,7 +105,7 @@ 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 WPosition PV_POSITION; //!< base type used for every WPVPosition
typedef WPosition_2 PV_POSITION; //!< base type used for every WPVPosition
typedef WColor PV_COLOR; //!< base type used for every WPVColor
typedef WMatrix4d_2 PV_MATRIX4X4; //!< base type used for every WPVMatrix4X4
......
......@@ -49,7 +49,7 @@ namespace
// m[i] = new double[rsize];
for( size_t j = 0; j < rsize; ++j )
{
m[i][j] = q[i].distanceSquare( r[j] );
m[i][j] = length2( q[i] - r[j] );
}
}
// compute dt(q,r)
......@@ -85,7 +85,7 @@ namespace
}
}
WFiber::WFiber( const std::vector< WPosition > &points )
WFiber::WFiber( const std::vector< WPosition_2 > &points )
: WLine( points )
{
}
......
......@@ -28,7 +28,7 @@
#include <vector>
#include "../math/WLine.h"
#include "../math/WPosition.h"
#include "../math/linearAlgebra/WLinearAlgebra.h"
#include "../WExportCommon.h"
class WFiberTest;
......@@ -41,11 +41,11 @@ class OWCOMMON_EXPORT WFiber : public WLine
friend class WFiberTest;
public:
/**
* Constructs a new fiber out of WPositions.
* Constructs a new fiber out of WPosition_2s.
*
* \param points Reference to the points which belong to this fiber
*/
explicit WFiber( const std::vector< WPosition > &points );
explicit WFiber( const std::vector< WPosition_2 > &points );
/**
* Creates an empty fiber.
......
......@@ -30,7 +30,7 @@
#include <cxxtest/TestSuite.h>
#include "../../math/WPosition.h"
#include "../../math/linearAlgebra/WLinearAlgebra.h"
#include "../WFiber.h"
#include "WFiberTraits.h"
......@@ -41,16 +41,16 @@ class WFiberTest : public CxxTest::TestSuite
{
public:
/**
* Two fibers are equal if they have equal WPositions in same order
* Two fibers are equal if they have equal WPosition_2s in same order
*/
void testEqualityOperator( void )
{
WFiber fib1;
WFiber fib2;
fib1.push_back( WPosition( 1.2, 3.4, 5.6 ) );
fib1.push_back( WPosition( 7.8, 9.0, -1.2 ) );
fib2.push_back( WPosition( 1.2, 3.4, 5.6 ) );
fib2.push_back( WPosition( 7.8, 9.0, -1.2 ) );
fib1.push_back( WPosition_2( 1.2, 3.4, 5.6 ) );
fib1.push_back( WPosition_2( 7.8, 9.0, -1.2 ) );
fib2.push_back( WPosition_2( 1.2, 3.4, 5.6 ) );
fib2.push_back( WPosition_2( 7.8, 9.0, -1.2 ) );
TS_ASSERT_EQUALS( fib1, fib2 );
}
......@@ -61,11 +61,11 @@ public:
void testDLTisSymmetric( void )
{
WFiber q;
q.push_back( WPosition( 0, 1, 0 ) );
q.push_back( WPosition( 0, 0, 0 ) );
q.push_back( WPosition_2( 0, 1, 0 ) );
q.push_back( WPosition_2( 0, 0, 0 ) );
WFiber r;
r.push_back( WPosition( 1, 1, 0 ) );
r.push_back( WPosition( 2, 2, 0 ) );
r.push_back( WPosition_2( 1, 1, 0 ) );
r.push_back( WPosition_2( 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 );
......@@ -78,11 +78,11 @@ public:
void testDSTisSymmetric( void )
{
WFiber q;
q.push_back( WPosition( 0, 1, 0 ) );
q.push_back( WPosition( 0, 0, 0 ) );
q.push_back( WPosition_2( 0, 1, 0 ) );
q.push_back( WPosition_2( 0, 0, 0 ) );
WFiber r;
r.push_back( WPosition( 1, 1, 0 ) );
r.push_back( WPosition( 2, 2, 0 ) );
r.push_back( WPosition_2( 1, 1, 0 ) );
r.push_back( WPosition_2( 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 );
......@@ -95,11 +95,11 @@ public:
void testDTMeasure( void )
{
WFiber q;
q.push_back( WPosition( 0, 1, 0 ) );
q.push_back( WPosition( 0, 0, 0 ) );
q.push_back( WPosition_2( 0, 1, 0 ) );
q.push_back( WPosition_2( 0, 0, 0 ) );
WFiber r;
r.push_back( WPosition( 1, 1, 0 ) );
r.push_back( WPosition( 2, 2, 0 ) );
r.push_back( WPosition_2( 1, 1, 0 ) );
r.push_back( WPosition_2( 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,7 +27,7 @@
#include "WGeometryFunctions.h"
void tesselateIcosahedron( std::vector< WVector3D >* vertices, std::vector< unsigned int >* triangles, unsigned int level )
void tesselateIcosahedron( std::vector< WVector3d_2 >* vertices, std::vector< unsigned int >* triangles, unsigned int level )
{
WAssert( vertices, "Missing input vector." );
WAssert( triangles, "Missing input vector." );
......@@ -47,24 +47,24 @@ void tesselateIcosahedron( std::vector< WVector3D >* vertices, std::vector< unsi
// add icosahedron vertices
double phi = 0.5 * ( 1.0 + sqrt( 5.0 ) );
std::vector< WVector3D > g;
std::vector< WVector3d_2 > g;
vertices->push_back( WVector3D( phi, 1, 0 ) ); // 0
vertices->push_back( WVector3D( -phi, 1, 0 ) ); // 1
vertices->push_back( WVector3D( phi, -1, 0 ) ); // 2
vertices->push_back( WVector3D( -phi, -1, 0 ) ); // 3
vertices->push_back( WVector3d_2( phi, 1, 0 ) ); // 0
vertices->push_back( WVector3d_2( -phi, 1, 0 ) ); // 1
vertices->push_back( WVector3d_2( phi, -1, 0 ) ); // 2
vertices->push_back( WVector3d_2( -phi, -1, 0 ) ); // 3
vertices->push_back( WVector3D( 1, 0, phi ) ); // 4
vertices->push_back( WVector3D( -1, 0, phi ) ); // 5
vertices->push_back( WVector3D( 1, 0, -phi ) ); // 6
vertices->push_back( WVector3D( -1, 0, -phi ) ); // 7
vertices->push_back( WVector3d_2( 1, 0, phi ) ); // 4
vertices->push_back( WVector3d_2( -1, 0, phi ) ); // 5
vertices->push_back( WVector3d_2( 1, 0, -phi ) ); // 6
vertices->push_back( WVector3d_2( -1, 0, -phi ) ); // 7
vertices->push_back( WVector3D( 0, phi, 1 ) ); // 8
vertices->push_back( WVector3D( 0, -phi, 1 ) ); // 9
vertices->push_back( WVector3D( 0, phi, -1 ) ); // 10
vertices->push_back( WVector3D( 0, -phi, -1 ) ); // 11
vertices->push_back( WVector3d_2( 0, phi, 1 ) ); // 8
vertices->push_back( WVector3d_2( 0, -phi, 1 ) ); // 9
vertices->push_back( WVector3d_2( 0, phi, -1 ) ); // 10
vertices->push_back( WVector3d_2( 0, -phi, -1 ) ); // 11
for( std::vector< WVector3D >::iterator it = vertices->begin(); it != vertices->end(); ++it )
for( std::vector< WVector3d_2 >::iterator it = vertices->begin(); it != vertices->end(); ++it )
{
*it = it->normalized();
}
......@@ -111,9 +111,9 @@ void tesselateIcosahedron( std::vector< WVector3D >* vertices, std::vector< unsi
utility::Edge e( ( *triangles )[ 3 * k + i ], ( *triangles )[ 3 * k + ( i + 1 ) % 3 ] );
if( edgeVertices.find( e ) == edgeVertices.end() )
{
WVector3D v0 = vertices->at( e.first );
WVector3D v1 = vertices->at( e.second );
WVector3D v = v0 + v1;
WVector3d_2 v0 = vertices->at( e.first );
WVector3d_2 v1 = vertices->at( e.second );
WVector3d_2 v = v0 + v1;
v = v.normalized();
vertices->push_back( v );
edgeVertices[ e ] = vertices->size() - 1;
......
......@@ -30,7 +30,7 @@
#include <vector>
#include "../WAssert.h"
#include "WVector3D.h"
#include "linearAlgebra/WLinearAlgebra.h"
namespace utility
{
......@@ -87,6 +87,6 @@ namespace utility
* \param[out] triangles The resulting triangles as a list of indices into the vertex vector.
* \param level The tesselation level.
*/
void OWCOMMON_EXPORT tesselateIcosahedron( std::vector< WVector3D >* vertices, std::vector< unsigned int >* triangles, unsigned int level );
void OWCOMMON_EXPORT tesselateIcosahedron( std::vector< WVector3d_2 >* vertices, std::vector< unsigned int >* triangles, unsigned int level );
#endif // WGEOMETRYFUNCTIONS_H
......@@ -35,19 +35,19 @@
#include "../WStringUtils.h"
#include "WLine.h"
#include "WPolynomialEquationSolvers.h"
#include "WPosition.h"
#include "linearAlgebra/WLinearAlgebra.h"
WLine::WLine( const std::vector< WPosition > &points )
: WMixinVector< WPosition >( points )
WLine::WLine( const std::vector< WPosition_2 > &points )
: WMixinVector< WPosition_2 >( points )
{
}
WLine::WLine()
: WMixinVector< WPosition >()
: WMixinVector< WPosition_2 >()
{
}
const WPosition& midPoint( const WLine& line )
const WPosition_2& midPoint( const WLine& line )
{
if( line.empty() )
{
......@@ -92,7 +92,7 @@ void WLine::resampleByNumberOfPoints( size_t numPoints )
// TODO(math): fix numerical issuses: newSegmentLength may be wrong => great offset by many intraSegment sample points
// remainingLength may be wrong => ...
// Take a look at the unit test testNumericalStabilityOfResampling
WPosition newPoint = at( i + 1 ) + remainingLength * ( at( i ) - at( i + 1 ) ).normalized();
WPosition_2 newPoint = at( i + 1 ) + remainingLength * ( at( i ) - at( i + 1 ) ).normalized();
newLine.push_back( newPoint );
// std::cout << "line size so far" << newLine.size() << " lenght so far: " << newLine.pathLength() << std::endl;
// std::cout << numPoints - newLine.size() << std::endl;
......@@ -113,7 +113,7 @@ void WLine::resampleByNumberOfPoints( size_t numPoints )
}
if( size() != numPoints )
{
this->WMixinVector< WPosition >::operator=( newLine );
this->WMixinVector< WPosition_2 >::operator=( newLine );
}
// Note if the size() == 0, then the resampled tract is also of length 0
}
......@@ -137,7 +137,7 @@ void WLine::removeAdjacentDuplicates()
newLine.push_back( *cit );
}
}
this->WMixinVector< WPosition >::operator=( newLine );
this->WMixinVector< WPosition_2 >::operator=( newLine );
}
void WLine::resampleBySegmentLength( double newSegmentLength )
......@@ -155,7 +155,7 @@ void WLine::resampleBySegmentLength( double newSegmentLength )
{
if( ( newLine.back() - ( *this )[i] ).norm() > newSegmentLength )
{
const WVector3D& pred = ( *this )[i - 1];
const WVector3d_2& pred = ( *this )[i - 1];
if( pred == newLine.back() )
{
// Then there is no triangle and the old Segment Length is bigger as the new segment
......@@ -185,7 +185,7 @@ void WLine::resampleBySegmentLength( double newSegmentLength )
// 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" );
WPosition pointOfIntersection;
WPosition_2 pointOfIntersection;
if( std::real( solution.first ) > 0.0 )
{
pointOfIntersection = pred + std::real( solution.first ) * ( ( *this )[i] - pred );
......@@ -201,10 +201,10 @@ void WLine::resampleBySegmentLength( double newSegmentLength )
}
if( ( newLine.back() - ( *this )[size() - 1] ).norm() > newSegmentLength / 2.0 )
{
WVector3D direction = ( ( *this )[size() - 1] - newLine.back() ).normalized();
WVector3d_2 direction = ( ( *this )[size() - 1] - newLine.back() ).normalized();
newLine.push_back( newLine.back() + direction * newSegmentLength );
}
this->WMixinVector< WPosition >::operator=( newLine );
this->WMixinVector< WPosition_2 >::operator=( newLine );
}
int equalsDelta( const WLine& line, const WLine& other, double delta )
......@@ -214,7 +214,7 @@ int equalsDelta( const WLine& line, const WLine& other, double delta )
bool sameLines = true;
for( diffPos = 0; ( diffPos < pts ) && sameLines; ++diffPos )
{
for( int x = 0; x < 3; ++x ) // since WLine uses WPosition as elements there are 3 components per position
for( int x = 0; x < 3; ++x ) // since WLine uses WPosition_2 as elements there are 3 components per position
{
sameLines = sameLines && ( std::abs( line[diffPos][x] - other[diffPos][x] ) <= delta );
}
......
......@@ -32,15 +32,15 @@
#include "../WBoundingBox.h"
#include "../WExportCommon.h"
#include "../WMixinVector.h"
#include "WPosition.h"
#include "linearAlgebra/WLinearAlgebra.h"
// forward declarations
class WLineTest;
/**
* A line is an ordered sequence of WPositions.
* A line is an ordered sequence of WPosition_2s.
*/
class OWCOMMON_EXPORT WLine : public WMixinVector< WPosition >
class OWCOMMON_EXPORT WLine : public WMixinVector< WPosition_2 >
{
public:
/**
......@@ -48,7 +48,7 @@ public:
*
* \param points Point sequence
*/
explicit WLine( const std::vector< WPosition > &points );
explicit WLine( const std::vector< WPosition_2 > &points );
/**
* Creates an empty line.
......@@ -114,7 +114,7 @@ OWCOMMON_EXPORT double pathLength( const WLine& line );
*
* \return Const reference to the midpoint element.
*/
OWCOMMON_EXPORT const WPosition& midPoint( const WLine& line );
OWCOMMON_EXPORT const WPosition_2& midPoint( const WLine& line );
/**
* Compares two lines with each other point wise upto a given delta.
......
......@@ -27,22 +27,22 @@
#include "../../ext/Eigen/SVD"
#include "../WAssert.h"
#include "../WLimits.h"
#include "WLinearAlgebraFunctions.h"
#include "WMatrix.h"
#include "WValue.h"
#include "WVector3D.h"
#include "linearAlgebra/WLinearAlgebra.h"
WVector3D multMatrixWithVector3D( WMatrix<double> mat, WVector3D vec )
WVector3d_2 multMatrixWithVector3D( WMatrix<double> mat, WVector3d_2 vec )
{
WVector3D result;
WVector3d_2 result;
result[0] = mat( 0, 0 ) * vec[0] + mat( 0, 1 ) * vec[1] + mat( 0, 2 ) * vec[2];
result[1] = mat( 1, 0 ) * vec[0] + mat( 1, 1 ) * vec[1] + mat( 1, 2 ) * vec[2];
result[2] = mat( 2, 0 ) * vec[0] + mat( 2, 1 ) * vec[1] + mat( 2, 2 ) * vec[2];
return result;
}
WVector3D transformVector3DWithMatrix4D( WMatrix<double> mat, WVector3D vec )
WVector3d_2 transformVector3DWithMatrix4D( WMatrix<double> mat, WVector3d_2 vec )
{
WAssert( mat.getNbRows() == 4 && mat.getNbCols() == 4, "Matrix has wrong size." );
std::vector< double > resultVec4D( 4 );
......@@ -51,14 +51,14 @@ WVector3D transformVector3DWithMatrix4D( WMatrix<double> mat, WVector3D vec )
resultVec4D[2] = mat( 2, 0 ) * vec[0] + mat( 2, 1 ) * vec[1] + mat( 2, 2 ) * vec[2] /* + mat( 2, 3 ) * 0 */;
resultVec4D[3] = mat( 3, 0 ) * vec[0] + mat( 3, 1 ) * vec[1] + mat( 3, 2 ) * vec[2] /* + mat( 3, 3 ) * 0 */;
WVector3D result;
WVector3d_2 result;
result[0] = resultVec4D[0] / resultVec4D[3];
result[1] = resultVec4D[1] / resultVec4D[3];
result[2] = resultVec4D[2] / resultVec4D[3];
return result;
}
WPosition transformPosition3DWithMatrix4D( WMatrix<double> mat, WPosition vec )
WPosition_2 transformPosition3DWithMatrix4D( WMatrix<double> mat, WPosition_2 vec )
{
WAssert( mat.getNbRows() == 4 && mat.getNbCols() == 4, "Matrix has wrong size." );
std::vector< double > resultVec4D( 4 );
......@@ -67,7 +67,7 @@ WPosition transformPosition3DWithMatrix4D( WMatrix<double> mat, WPosition vec )
resultVec4D[2] = mat( 2, 0 ) * vec[0] + mat( 2, 1 ) * vec[1] + mat( 2, 2 ) * vec[2] + mat( 2, 3 ) * 1;
resultVec4D[3] = mat( 3, 0 ) * vec[0] + mat( 3, 1 ) * vec[1] + mat( 3, 2 ) * vec[2] + mat( 3, 3 ) * 1;
WVector3D result;
WVector3d_2 result;
result[0] = resultVec4D[0] / resultVec4D[3];
result[1] = resultVec4D[1] / resultVec4D[3];
result[2] = resultVec4D[2] / resultVec4D[3];
......@@ -283,9 +283,9 @@ WMatrix<double> invertMatrix4x4( WMatrix<double> mat )
return result;
}
bool linearIndependent( const WVector3D& u, const WVector3D& v )
bool linearIndependent( const WVector3d_2& u, const WVector3d_2& v )
{
WVector3D cp = u.crossProduct( v );
WVector3d_2 cp = cross( u, v );
if( std::fabs( cp[0] ) < wlimits::DBL_EPS && std::fabs( cp[1] ) < wlimits::DBL_EPS && std::fabs( cp[2] ) < wlimits::DBL_EPS )
{
return false;
......
......@@ -29,14 +29,6 @@
#include "WMatrix.h"
#include "linearAlgebra/WLinearAlgebra.h"
namespace osg
{
class Matrixd;
}
class WVector3D;
typedef WVector3D WPosition;
template< typename > class WValue;
template< typename > class WMatrix;
/**
......@@ -45,7 +37,7 @@ template< typename > class WMatrix;
* \param mat 3x3 matrix
* \param vec vector
*/
WVector3D OWCOMMON_EXPORT multMatrixWithVector3D( WMatrix<double> mat, WVector3D vec );
WVector3d_2 OWCOMMON_EXPORT multMatrixWithVector3D( WMatrix<double> mat, WVector3d_2 vec );
/**
* Applies a coordinate transformation in homogenous coordinates to a vector.
......@@ -54,7 +46,7 @@ WVector3D OWCOMMON_EXPORT multMatrixWithVector3D( WMatrix<double> mat, WVector3D
* \param mat 4x4 matrix
* \param vec vector
*/
WVector3D OWCOMMON_EXPORT transformVector3DWithMatrix4D( WMatrix<double> mat, WVector3D vec );
WVector3d_2 OWCOMMON_EXPORT transformVector3DWithMatrix4D( WMatrix<double> mat, WVector3d_2 vec );
/**
* Applies a coordinate transformation in homogenous coordinates to a position.
......@@ -63,7 +55,7 @@ WVector3D OWCOMMON_EXPORT transformVector3DWithMatrix4D( WMatrix<double> mat, WV
* \param mat 4x4 matrix
* \param vec vector
*/
WVector3D OWCOMMON_EXPORT transformPosition3DWithMatrix4D( WMatrix<double> mat, WPosition vec );
WVector3d_2 OWCOMMON_EXPORT transformPosition3DWithMatrix4D( WMatrix<double> mat, WPosition_2 vec );
/**
* helper routine to invert a 3x3 matrix
......@@ -93,7 +85,7 @@ WMatrix<double> OWCOMMON_EXPORT invertMatrix4x4( WMatrix<double> mat );
*
* \note This check is performed with the cross product != (0,0,0) but in numerical stability with FLT_EPS.
*/
bool OWCOMMON_EXPORT linearIndependent( const WVector3D& u, const WVector3D& v );
bool OWCOMMON_EXPORT linearIndependent( const WVector3d_2& u, const WVector3d_2& v );
/**
* Computes the SVD for the Matrix \param A
......
......@@ -24,19 +24,19 @@
#include "WMath.h"
#include "WPlane.h"
#include "WPosition.h"
#include "WVector3D.h"
#include "linearAlgebra/WLinearAlgebra.h"
#include "linearAlgebra/WLinearAlgebra.h"
#include "../WAssert.h"
#include "../WLimits.h"
bool testIntersectTriangle( const WPosition& p1, const WPosition& p2, const WPosition& p3, const WPlane& p )
bool testIntersectTriangle( const WPosition_2& p1, const WPosition_2& p2, const WPosition_2& p3, const WPlane& p )
{
const WVector3D& normal = p.getNormal();
const WPosition& planePoint = p.getPosition();
const WVector3d_2& normal = p.getNormal();
const WPosition_2& planePoint = p.getPosition();
double r1 = normal.dotProduct( p1 - planePoint );
double r2 = normal.dotProduct( p2 - planePoint );
double r3 = normal.dotProduct( p3 - planePoint );
double r1 = dot( normal, p1 - planePoint );
double r2 = dot( normal, p2 - planePoint );
double r3 = dot( normal, p3 - planePoint );
// TODO(math): use signum here!
if( std::abs( ( ( r1 > 0 ) - ( r1 < 0 ) ) + ( ( r2 > 0) - ( r2 < 0 ) ) + ( ( r3 > 0 ) - ( r3 < 0 ) ) ) == 3 )
......@@ -47,33 +47,33 @@ bool testIntersectTriangle( const WPosition& p1, const WPosition& p2, const WPos
}
bool intersectPlaneSegment( const WPlane& p,
const WPosition& p1,
const WPosition& p2,
boost::shared_ptr< WPosition > pointOfIntersection )
const WPosition_2& p1,
const WPosition_2& p2,
boost::shared_ptr< WPosition_2 > pointOfIntersection )
{
const WVector3D& normal = p.getNormal().normalized();
double const d = normal.dotProduct( p.getPosition() );
const WVector3d_2& normal = p.getNormal().normalized();
double const d = dot( normal, p.getPosition() );
WAssert( pointOfIntersection.get(), "Place to store a point of intersection is not ready!" );
*pointOfIntersection = p.getPosition(); // otherwise it would be undefined
// at least one point is in plane (maybe the whole segment)
if( std::abs( normal.dotProduct( p1 - p.getPosition() ) ) <= 2*wlimits::DBL_EPS )
if( std::abs( dot( normal, p1 - p.getPosition() ) ) <= 2 * wlimits::DBL_EPS )