#include <GeoSphere.h>
|
| Sphere () |
| Default ctor. More...
|
|
virtual | ~Sphere () |
| Default dtor. More...
|
|
| Sphere (const double &x, const double &y, const double &z, const double &r) |
| Alternative ctor (0) More...
|
|
| Sphere (const Point_t ¢er, const double r=0) |
| Altenartive ctor (1) - 1 Point. More...
|
|
| Sphere (const Point_t &pt1, const Point_t &pt2) |
| Alternative ctor (2) - 2 Points. More...
|
|
| Sphere (const Point_t &A, const Point_t &B, const Point_t &C) |
| Alternative ctor (3) - 3 Points. More...
|
|
| Sphere (const Point_t &A, const Point_t &B, const Point_t &C, const Point_t &D) |
|
| Sphere (const std::vector< ::geoalgo::Point_t > &pts) |
|
const Point_t & | Center () const |
| Center getter. More...
|
|
double | Radius () const |
| Radius getter. More...
|
|
void | Center (const double x, const double y, const double z) |
| Center setter. More...
|
|
void | Center (const Point_t &pt) |
| Center setter. More...
|
|
void | Radius (const double &r) |
| Radius setter. More...
|
|
bool | Contain (const Point_t &p) const |
| Judge if a point is contained within a sphere. More...
|
|
template<class T > |
| Sphere (const T &pt1, const T &pt2) |
|
template<class T > |
| Sphere (const T &A, const T &B, const T &C) |
|
template<class T > |
| Sphere (const T &A, const T &B, const T &C, const T &D) |
|
template<class T > |
| Sphere (const std::vector< T > &pts) |
|
template<class T > |
void | Center (const T &pt) |
|
template<class T > |
bool | Contain (const T &p) const |
|
|
void | compat (const Point_t &p, const double r=0) const |
| 3D point compatibility check More...
|
|
void | compat (const double &r) const |
| Positive radius compatibility check. More...
|
|
Definition at line 27 of file GeoSphere.h.
geoalgo::Sphere::Sphere |
( |
| ) |
|
Default ctor.
Definition at line 8 of file GeoSphere.cxx.
Point_t _center
Center of Sphere.
double _radius
Radius of Sphere.
virtual geoalgo::Sphere::~Sphere |
( |
| ) |
|
|
inlinevirtual |
geoalgo::Sphere::Sphere |
( |
const double & |
x, |
|
|
const double & |
y, |
|
|
const double & |
z, |
|
|
const double & |
r |
|
) |
| |
Alternative ctor (0)
Definition at line 12 of file GeoSphere.cxx.
Point_t _center
Center of Sphere.
double _radius
Radius of Sphere.
geoalgo::Sphere::Sphere |
( |
const Point_t & |
center, |
|
|
const double |
r = 0 |
|
) |
| |
Altenartive ctor (1) - 1 Point.
Definition at line 16 of file GeoSphere.cxx.
Point_t _center
Center of Sphere.
double _radius
Radius of Sphere.
Alternative ctor (2) - 2 Points.
Definition at line 20 of file GeoSphere.cxx.
Point_t _center
Center of Sphere.
void compat(const Point_t &p, const double r=0) const
3D point compatibility check
double _radius
Radius of Sphere.
Alternative ctor (3) - 3 Points.
Definition at line 31 of file GeoSphere.cxx.
48 double dABAB = AB.Dot(AB);
49 double dACAC = AC.Dot(AC);
50 double dABAC = AB.Dot(AC);
52 double d = dABAB * dACAC - dABAC * dABAC;
58 double lenAB = AB.Length();
59 double lenAC = AC.Length();
60 double lenBC = BC.Length();
62 if ( (lenAB > lenAC) && (lenAB > lenBC) ){
66 else if( lenAC > lenBC ){
77 s = 0.5 * ( dABAB * dACAC - dACAC * dABAC ) / d;
78 t = 0.5 * ( dACAC * dABAB - dABAB * dABAC ) / d;
81 if ( (s > 0) && (t > 0) && ((1-s-t) > 0) ){
double Dist(const Vector &obj) const
Compute the distance to another vector.
Point_t _center
Center of Sphere.
void compat(const Point_t &p, const double r=0) const
3D point compatibility check
double _radius
Radius of Sphere.
recob::tracking::Vector_t Vector_t
QTextStream & endl(QTextStream &s)
Definition at line 183 of file GeoSphere.cxx.
192 std::vector<geoalgo::Point_t> valid_points = {
A};
193 bool duplicate =
false;
194 for (
auto const& pt : valid_points){
195 if (pt.SqDist(
B) < 0.0001)
198 if (duplicate ==
false)
199 valid_points.push_back(
B);
201 for (
auto const& pt : valid_points){
202 if (pt.SqDist(
C) < 0.0001)
205 if (duplicate ==
false)
206 valid_points.push_back(
C);
208 for (
auto const& pt : valid_points){
209 if (pt.SqDist(
D) < 0.0001)
212 if (duplicate ==
false)
213 valid_points.push_back(
D);
216 if (valid_points.size() < 4){
217 (*this) =
Sphere(valid_points);
226 double dABAB = AB.Dot(AB);
227 double dACAC = AC.Dot(AC);
228 double dADAD = AD.Dot(AD);
229 double dABAC = AB.Dot(AC);
230 double dABAD = AB.Dot(AD);
231 double dACAD = AC.Dot(AD);
233 double d = 4*dABAC*dABAD*dACAD;
239 throw GeoAlgoException(
"GeoSphere Exception: I think it means 3 points collinear. Find out which and call 3 point constructor - TO DO");
242 double s = (dABAC*dACAD*dADAD + dABAD*dACAC*dACAD - dABAB*dACAD*dACAD)/d;
243 double t = (dABAB*dACAD*dABAD + dABAD*dABAC*dADAD - dABAD*dABAD*dACAC)/d;
244 double u = (dABAB*dABAC*dACAD + dABAC*dABAD*dACAC - dABAC*dABAC*dADAD)/d;
247 if ( (s > 0) && (t > 0) && (u > 0) && ((1-s-t-u) > 0) ){
253 double maxdist =
A.Dist(
B);
256 if (
A.Dist(
C) > maxdist){
261 if (
A.Dist(
D) > maxdist){
266 if (
B.Dist(
C) > maxdist){
271 if (
B.Dist(
D) > maxdist){
276 if (
C.Dist(
D) > maxdist){
double Dist(const Vector &obj) const
Compute the distance to another vector.
Point_t _center
Center of Sphere.
void compat(const Point_t &p, const double r=0) const
3D point compatibility check
double _radius
Radius of Sphere.
recob::tracking::Vector_t Vector_t
Definition at line 322 of file GeoSphere.cxx.
332 case 2: (*this) =
Sphere(pts[0],pts[1]);
334 case 3: (*this) =
Sphere(pts[0],pts[1],pts[2]);
336 case 4: (*this) =
Sphere(pts[0],pts[1],pts[2],pts[3]);
339 throw GeoAlgoException(
"Cannot call Sphere constructor with more than 4 points. Something went wront");
Point_t _center
Center of Sphere.
double _radius
Radius of Sphere.
template<class T >
geoalgo::Sphere::Sphere |
( |
const T & |
pt1, |
|
|
const T & |
pt2 |
|
) |
| |
|
inline |
template<class T >
geoalgo::Sphere::Sphere |
( |
const T & |
A, |
|
|
const T & |
B, |
|
|
const T & |
C |
|
) |
| |
|
inline |
template<class T >
geoalgo::Sphere::Sphere |
( |
const T & |
A, |
|
|
const T & |
B, |
|
|
const T & |
C, |
|
|
const T & |
D |
|
) |
| |
|
inline |
template<class T >
geoalgo::Sphere::Sphere |
( |
const std::vector< T > & |
pts | ) |
|
|
inline |
Definition at line 105 of file GeoSphere.h.
107 std::vector< ::geoalgo::Vector> geo_pts;
108 geo_pts.reserve(pts);
109 for(
auto const&
p : pts) geo_pts.emplace_back(
p);
110 (*this) =
Sphere(geo_pts);
const Point_t & geoalgo::Sphere::Center |
( |
| ) |
const |
Center getter.
Definition at line 344 of file GeoSphere.cxx.
Point_t _center
Center of Sphere.
void geoalgo::Sphere::Center |
( |
const double |
x, |
|
|
const double |
y, |
|
|
const double |
z |
|
) |
| |
Center setter.
Definition at line 348 of file GeoSphere.cxx.
Point_t _center
Center of Sphere.
void geoalgo::Sphere::Center |
( |
const Point_t & |
pt | ) |
|
Center setter.
Definition at line 351 of file GeoSphere.cxx.
Point_t _center
Center of Sphere.
void compat(const Point_t &p, const double r=0) const
3D point compatibility check
template<class T >
void geoalgo::Sphere::Center |
( |
const T & |
pt | ) |
|
|
inline |
Definition at line 113 of file GeoSphere.h.
const Point_t & Center() const
Center getter.
void geoalgo::Sphere::compat |
( |
const Point_t & |
p, |
|
|
const double |
r = 0 |
|
) |
| const |
|
protected |
3D point compatibility check
Definition at line 363 of file GeoSphere.cxx.
365 if(
p.size()!=3)
throw GeoAlgoException(
"Only 3D points allowed for sphere");
void compat(const Point_t &p, const double r=0) const
3D point compatibility check
void geoalgo::Sphere::compat |
( |
const double & |
r | ) |
const |
|
protected |
Positive radius compatibility check.
Definition at line 369 of file GeoSphere.cxx.
370 {
if(
r<0)
throw GeoAlgoException(
"Only positive value allowed for radius"); }
bool geoalgo::Sphere::Contain |
( |
const Point_t & |
p | ) |
const |
Judge if a point is contained within a sphere.
Definition at line 357 of file GeoSphere.cxx.
void compat(const Vector &obj) const
Dimensional check for a compatibility.
Point_t _center
Center of Sphere.
double _radius
Radius of Sphere.
template<class T >
bool geoalgo::Sphere::Contain |
( |
const T & |
p | ) |
const |
|
inline |
Definition at line 116 of file GeoSphere.h.
bool Contain(const Point_t &p) const
Judge if a point is contained within a sphere.
double geoalgo::Sphere::Radius |
( |
| ) |
const |
Radius getter.
Definition at line 346 of file GeoSphere.cxx.
double _radius
Radius of Sphere.
void geoalgo::Sphere::Radius |
( |
const double & |
r | ) |
|
Radius setter.
Definition at line 354 of file GeoSphere.cxx.
void compat(const Point_t &p, const double r=0) const
3D point compatibility check
double _radius
Radius of Sphere.
double geoalgo::Sphere::_radius |
|
protected |
The documentation for this class was generated from the following files: