Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
76a8f9d
Template the GenVector Plane3D, Transform3D and Translation3D classes…
cjones051073 Feb 25, 2017
7e9c2b7
Use the 'using namespace std' trick with Cartesian3D and Plane3D to f…
cjones051073 Feb 25, 2017
b15d62a
Extend the 'using namespace std' trick to a few more classes
cjones051073 Feb 25, 2017
2b2fc17
Change class to typename
cjones051073 Feb 25, 2017
2e74f0d
Explicitly cast some constants to the scalar type (needed for Vc types)
cjones051073 Feb 25, 2017
c3175c6
Remove empty implementation files
cjones051073 Feb 25, 2017
9bdfb8e
Template the Boost classes
cjones051073 Feb 25, 2017
c97245c
Remove empty implementation files for Boost classes
cjones051073 Feb 25, 2017
f12d368
Clean up some indentations
cjones051073 Feb 25, 2017
bbbbbd0
Add some missing template types to the Boost classes
cjones051073 Feb 25, 2017
9a0ee77
Remove empty Boost implementation file
cjones051073 Feb 25, 2017
371d50d
Small cleanups
cjones051073 Feb 25, 2017
dcb0b30
Clean up some initialisations
cjones051073 Feb 25, 2017
29e7e30
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Feb 27, 2017
14e73b4
Add Scalar/Vector Plane3D::Normalise() methods using SFINAE
cjones051073 Feb 27, 2017
27bbb57
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Feb 27, 2017
196a00b
Roll back some changes for now, as they are causing problems in the t…
cjones051073 Feb 27, 2017
0ad5828
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Feb 27, 2017
1928c75
Add specific vectorised implementations of a few methods
cjones051073 Feb 28, 2017
5ccdaea
Extend ostream operator for Displacement and Position vectors to supp…
cjones051073 Feb 28, 2017
ef1aea9
Fix the vector abs method (not fabs) and Vector Unit() for vectorised…
cjones051073 Feb 28, 2017
6cac16a
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Feb 28, 2017
68ba28a
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Mar 1, 2017
939b7cb
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Mar 4, 2017
d9b810b
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Mar 6, 2017
776ce1a
Add override qualifier
cjones051073 Mar 6, 2017
fbe74d2
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Mar 10, 2017
12b43b0
Fix initialisation bug
cjones051073 Mar 10, 2017
8367bdf
remove space
cjones051073 Mar 10, 2017
0f404ba
Some small changes following review comments
cjones051073 Mar 10, 2017
65a701d
remove spaces
cjones051073 Mar 10, 2017
4ba8a1b
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Mar 10, 2017
ff94a5a
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Mar 11, 2017
b8ca822
Fix formatting using clang-format
cjones051073 Mar 11, 2017
b32cb6a
some more 'using namespace std' updates
cjones051073 Mar 11, 2017
febe783
Fix more clang format issues
cjones051073 Mar 11, 2017
a628a2a
fix (hopefully) one more clang format issue
cjones051073 Mar 11, 2017
89b2d26
clang format is picky...
cjones051073 Mar 11, 2017
6bf0368
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Mar 11, 2017
bd96bd0
revert changes in VectorUtils.h
cjones051073 Mar 13, 2017
dea8d05
Add new test for GenVector with Vc types
cjones051073 Mar 13, 2017
a18221a
extend test to 96 photons
cjones051073 Mar 13, 2017
eb0b8ed
reorder headers
cjones051073 Mar 13, 2017
7da1945
remove comment that number of test photons must be multiple of 8, as …
cjones051073 Mar 13, 2017
a271eab
Add <cmath> header includes
cjones051073 Mar 13, 2017
decbe11
revert back to using std:: as it seems to cause issues with gcc build…
cjones051073 Mar 14, 2017
58c6315
Include Vc before ROOT in test application. Needed for std:: support...
cjones051073 Mar 14, 2017
17f42a3
Add some more missing std::
cjones051073 Mar 14, 2017
434396d
More math updates
cjones051073 Mar 14, 2017
b145899
Change enable_if implementation in GenVector
cjones051073 Mar 14, 2017
ad8d3a5
update comment
cjones051073 Mar 14, 2017
b018a03
Extend the GenVector Vc test with a timing test that asserts that the…
cjones051073 Mar 14, 2017
bb1e386
add fabs on timing diff and extend Vc genvector expected diff to 25%
cjones051073 Mar 14, 2017
1786383
do not return a failure from the Vc speed test, as test could be run …
cjones051073 Mar 14, 2017
380dd35
Update enable_if pattern in GenVector Vc test
cjones051073 Mar 15, 2017
ccd81f3
resolve conflicts
cjones051073 Mar 15, 2017
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
Next Next commit
Template the GenVector Plane3D, Transform3D and Translation3D classes…
… on their scalar type
  • Loading branch information
cjones051073 committed Feb 25, 2017
commit 76a8f9db222c8a77460591262c3623aadbb87a1b
120 changes: 88 additions & 32 deletions math/genvector/inc/Math/GenVector/Plane3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace ROOT {

namespace Math {


namespace Impl {

//_______________________________________________________________________________
/**
Expand All @@ -38,22 +38,24 @@ namespace Math {
belonging to plane.
More information on the mathematics describing a plane in 3D is available on
<A HREF=http://mathworld.wolfram.com/Plane.html>MathWord</A>.
The Plane3D class contains the 4 scalar values in double which represent the
The Plane3D class contains the 4 scalar values in T which represent the
four coefficients, fA, fB, fC, fD. fA, fB, fC are the normal components normalized to 1,
i.e. fA**2 + fB**2 + fC**2 = 1

@ingroup GenVector
*/

template <class T = double>
class Plane3D {

public:

// ------ ctors ------

typedef double Scalar;
typedef T Scalar;

typedef DisplacementVector3D<Cartesian3D<double>, DefaultCoordinateSystemTag > Vector;
typedef PositionVector3D<Cartesian3D<double>, DefaultCoordinateSystemTag > Point;
typedef DisplacementVector3D<Cartesian3D<T>, DefaultCoordinateSystemTag > Vector;
typedef PositionVector3D<Cartesian3D<T>, DefaultCoordinateSystemTag > Point;



Expand All @@ -70,12 +72,18 @@ namespace Math {
\param c scalar value
\param d sxcalar value
*/
Plane3D(const Scalar & a, const Scalar & b, const Scalar & c, const Scalar & d);
Plane3D(const Scalar & a, const Scalar & b, const Scalar & c, const Scalar & d)
: fA(a), fB(b), fC(c), fD(d)
{
//renormalize a,b,c to unit
Normalize();
}


/**
constructor a Plane3D from a normal vector and a point coplanar to the plane
\param n normal expressed as a ROOT::Math::DisplacementVector3D<Cartesian3D<double> >
\param p point expressed as a ROOT::Math::PositionVector3D<Cartesian3D<double> >
\param n normal expressed as a ROOT::Math::DisplacementVector3D<Cartesian3D<T> >
\param p point expressed as a ROOT::Math::PositionVector3D<Cartesian3D<T> >
*/
Plane3D(const Vector & n, const Point & p )
{
Expand Down Expand Up @@ -107,9 +115,9 @@ namespace Math {

/**
constructor from three generic point belonging to the plane
\param p1 point1 expressed as ROOT::Math::DisplacementVector3D<Cartesian3D<double> >
\param p2 point2 expressed as ROOT::Math::DisplacementVector3D<Cartesian3D<double> >
\param p3 point3 expressed as ROOT::Math::DisplacementVector3D<Cartesian3D<double> >
\param p1 point1 expressed as ROOT::Math::DisplacementVector3D<Cartesian3D<T> >
\param p2 point2 expressed as ROOT::Math::DisplacementVector3D<Cartesian3D<T> >
\param p3 point3 expressed as ROOT::Math::DisplacementVector3D<Cartesian3D<T> >
*/
template <class T1, class T2, class T3, class U>
Plane3D(const PositionVector3D<T1,U> & p1, const PositionVector3D<T2,U> & p2, const PositionVector3D<T3,U> & p3 )
Expand Down Expand Up @@ -182,33 +190,38 @@ namespace Math {
normal vector to the plane.
\param p Point expressed in Cartesian Coordinates
*/
Scalar Distance(const Point & p) const;

Scalar Distance(const Point & p) const
{
return fA*p.X() + fB*p.Y() + fC*p.Z() + fD;
}

/**
Return the distance to a Point described with generic coordinates
\param p Point expressed as generic ROOT::Math::PositionVector3D
*/
template <class T, class U>
Scalar Distance(const PositionVector3D<T,U> & p) const {
template <class T1, class U>
Scalar Distance(const PositionVector3D<T1,U> & p) const {
return Distance( Point(p.X(), p.Y(), p.Z() ) );
}

/**
Return the projection of a Cartesian point to a plane
\param p Point expressed as PositionVector3D<Cartesian3D<double> >
\param p Point expressed as PositionVector3D<Cartesian3D<T> >
*/
Point ProjectOntoPlane(const Point & p) const;
Point ProjectOntoPlane(const Point & p) const
{
const Scalar d = Distance(p);
return XYZPoint( p.X() - fA*d, p.Y() - fB*d, p.Z() - fC*d);
}

/**
Return the projection of a point to a plane
\param p Point expressed as generic ROOT::Math::PositionVector3D
*/
template <class T, class U>
PositionVector3D<T,U> ProjectOntoPlane(const PositionVector3D<T,U> & p) const {
Point pxyz = ProjectOntoPlane(Point(p.X(), p.Y(), p.Z() ) );
PositionVector3D<T,U> p2;
p2.SetXYZ( pxyz.X(), pxyz.Y(), pxyz.Z() );
return p2;
template <class T1, class U>
PositionVector3D<T1,U> ProjectOntoPlane(const PositionVector3D<T1,U> & p) const {
const Point pxyz = ProjectOntoPlane(Point(p.X(), p.Y(), p.Z() ) );
return PositionVector3D<T,U>( pxyz.X(), pxyz.Y(), pxyz.Z() );
}


Expand All @@ -230,16 +243,46 @@ namespace Math {
/**
Normalize the normal (a,b,c) plane components
*/
void Normalize();

void Normalize()
{
// normalize the plane
const Scalar s = std::sqrt( fA*fA + fB*fB + fC*fC );
// what to do if s = 0 ??
// CRJ - This does not work with Vc types... ToDo decide how to handle...
//if ( s == 0 ) { fD = 0; return; }
const Scalar w = Scalar(1)/s;
fA *= w;
fB *= w;
fC *= w;
fD *= w;
}

private:

// internal method to construct class from a vector and a point
void BuildFromVecAndPoint(const Vector & n, const Point & p);
void BuildFromVecAndPoint(const Vector & n, const Point & p)
{
// build from a normal vector and a point
fA = n.X();
fB = n.Y();
fC = n.Z();
fD = - n.Dot(p);
Normalize();
}

// internal method to construct class from 3 points
void BuildFrom3Points(const Point & p1, const Point & p2, const Point & p3);

void BuildFrom3Points(const Point & p1, const Point & p2, const Point & p3)
{
// plane from thre points
// normal is (x3-x1) cross (x2 -x1)
const Vector n = (p2-p1).Cross(p3-p1);
fA = n.X();
fB = n.Y();
fC = n.Z();
fD = - n.Dot(p1);
Normalize();
}

// plane data members the four scalar which satisfies fA*x + fB*y + fC*z + fD = 0
// for every point (x,y,z) belonging to the plane.
// fA**2 + fB**2 + fC** =1 plane is stored in normalized form
Expand All @@ -255,10 +298,23 @@ namespace Math {
Stream Output and Input
*/
// TODO - I/O should be put in the manipulator form

std::ostream & operator<< (std::ostream & os, const Plane3D & p);


template < typename T >
std::ostream & operator<< (std::ostream & os, const Plane3D<T> & p)
{
os << "\n" << p.Normal().X()
<< " " << p.Normal().Y()
<< " " << p.Normal().Z()
<< " " << p.HesseDistance()
<< "\n";
return os;
}

} // end namespace Impl

// typedefs for double and float versions
typedef Impl::Plane3D<double> Plane3D;
typedef Impl::Plane3D<float> Plane3DF;

} // end namespace Math

} // end namespace ROOT
Expand Down
Loading