10 #ifndef LARCOREALG_GEOMETRY_DECOMPOSER_H 11 #define LARCOREALG_GEOMETRY_DECOMPOSER_H 18 #include <type_traits> 37 template <
typename Vector>
97 template <
typename Vector,
typename Po
int = Vector>
107 : fOrigin(origin), fBase(main, secondary)
142 template <
typename ProjVector>
156 : projection(projection), distance(distance)
160 : projection(projection), distance(distance)
176 template <
typename Vector,
typename Po
int,
typename ProjVector>
199 : fPlaneBase({0.0, 0.0, 0.0},
268 return VectorMainComponent(Base().ToVector(point));
274 return VectorSecondaryComponent(Base().ToVector(point));
290 return VectorProjection(Base().ToVector(point));
314 return {VectorMainComponent(v), VectorSecondaryComponent(v)};
330 double const a = std::atan2(VectorSecondaryComponent(v), VectorMainComponent(v));
331 return (a >= M_PI) ? -M_PI : a;
351 return MainComponent(projection) *
MainDir() +
368 return ReferencePoint() + ComposeVector(projection);
387 template <
typename Vector,
typename Po
int,
typename ProjVector>
471 return VectorMainComponent(Base().ToVector(point));
477 return VectorSecondaryComponent(Base().ToVector(point));
483 return VectorNormalComponent(Base().ToVector(point));
499 return Plane().PointProjection(point);
518 return DecomposeVector(Base().ToVector(point));
532 return Plane().VectorSecondaryComponent(v);
551 return Plane().VectorProjection(v);
570 return {VectorNormalComponent(v), ProjectVectorOnPlane(v)};
612 return ComposePoint(decomp.distance, decomp.projection);
635 return ReferencePoint() + ComposeVector(distance, proj);
653 return ComposeVector(decomp.distance, decomp.projection);
688 #endif // LARCOREALG_GEOMETRY_DECOMPOSER_H Point_t ComposePoint(DecomposedVector_t const &decomp) const
Returns the 3D point from composition of projection and distance.
void SetBase(AffinePlaneBase_t const &base)
Change projection base.
auto VectorSecondaryComponent(Vector_t const &v) const
Returns the secondary component of a vector.
Vector_t fSecondary
Secondary axis on the plane.
Projection_t projection
Projection of the vector on the plane.
typename PlaneDecomposer_t::Distance_t Distance_t
Type representing the signed distance from the projection plane.
Distance_t distance
Distance of the vector from the plane.
auto PointNormalComponent(Point_t const &point) const
Returns the secondary component of a point.
Point_t ComposePoint(double distance, Projection_t const &proj) const
Returns the 3D point from composition of projection and distance.
Vector_t fNormal
Axis normal to the plane.
void SetSecondaryDir(Vector_t const &dir)
Change the secondary direction of the projection base.
Vector_t const & SecondaryDir() const
Returns the secondary axis direction.
auto VectorMainComponent(Vector_t const &v) const
Returns the main component of a projection vector.
AffinePlaneBase(Point_t const &origin, Vector_t const &main, Vector_t const &secondary)
Constructor: assigns the origin of the system and the axes.
Vector_t const & NormalDir() const
Returns the plane normal axis direction.
PlaneBase(Vector_t const &main, Vector_t const &secondary)
Constructor: assigns the axes.
void SetMainDir(Vector_t const &dir)
Change the main direction of the projection base.
Vector_t ToVector(Point_t const &point) const
Returns the vector representing the specified point in the affine space.
auto SecondaryComponent(Projection_t const &v) const
Returns the secondary component of a projection vector.
Vector_t const & NormalDir() const
Returns the axis normal to the plane.
Point_t fOrigin
Origin of the coordinate system.
Vector_t ComposeVector(DecomposedVector_t const &decomp) const
Returns the 3D vector from composition of projection and distance.
void SetSecondaryDir(Vector_t const &dir)
Change the secondary direction of the projection base.
auto PointMainComponent(Point_t const &point) const
Returns the main component of a point.
Point_t Origin() const
Returns the origin of the coordinate system in world coordinates.
Class with methods to decompose and compose back vectors.
DecomposedVector_t DecomposeVector(Vector_t const &v) const
Decomposes a 3D vector in two components.
Vector_t const & MainDir() const
Returns the plane main axis direction.
Projection_t VectorProjection(Vector_t const &v) const
Returns the projection of the specified vector on the plane.
typename AffinePlaneBase_t::Point_t Point_t
Type for a point.
Vector_t const & MainDir() const
Returns the main axis direction.
void SetBase(AffinePlaneBase_t &&base)
Change projection base.
PlaneDecomposer(AffinePlaneBase_t &&base)
Constructor: specifies a base (an origin and two direction vectors)
DecomposedVector(Distance_t distance, Projection_t const &projection)
auto VectorNormalComponent(Vector_t const &v) const
Returns the secondary component of a vector.
Projection_t PointProjection(Point_t const &point) const
Returns the projection of the specified point on the plane.
recob::tracking::Point_t Point_t
static Vector_t PastorizeUnitVector(Vector_t dir)
Normalizes and rounds a direction vector.
Projection_t ProjectPointOnPlane(Point_t const &point) const
Returns the projection of the specified point on the plane.
PlaneDecomposer_t const & Plane() const
Returns the plane decomposer.
void SetOrigin(Point_t const &point)
Change the 3D point of the reference frame origin.
typename PlaneDecomposer_t::Projection_t Projection_t
Type representing the projection vector.
typename PlaneBase_t::Vector_t Vector_t
Vector in space.
Vector_t ComposeVector(double distance, Projection_t const &proj) const
Returns the 3D vector from composition of projection and distance.
auto MainComponent(Projection_t const &v) const
Returns the main component of a projection vector.
auto SecondaryComponent(Projection_t const &v) const
Returns the secondary component of a projection vector.
AffinePlaneBase_t const & Base() const
Returns the complete base representation.
auto PointSecondaryComponent(Point_t const &point) const
Returns the secondary component of a 3D point.
Decomposer(AffinePlaneBase_t &&base)
Constructor: specifies a base (an origin and two direction vectors)
typename PlaneDecomposer_t::AffinePlaneBase_t AffinePlaneBase_t
Type of vector base for the space.
AffinePlaneBase_t const & Base() const
Returns the base of the decomposition.
PlaneDecomposer()
Default constructor: projection on (x,y) with origin (0, 0, 0)
auto MainComponent(Projection_t const &v) const
Returns the main component of a projection vector.
DecomposedVector(Projection_t const &projection, Distance_t distance)
Utilities to extend the interface of geometry vectors.
decltype(geo::vect::mag2(std::declval< Projection_t >())) Distance_t
Type for distance from plane.
DecomposedVector_t DecomposePoint(Point_t const &point) const
Decomposes a 3D point in two components.
double Angle(Vector_t const &v) const
Returns the angle of the projection from main direction.
void SetBase(AffinePlaneBase_t const &base)
Change projection base.
void SetOrigin(Point_t const &point)
Change the 3D point of the reference frame origin.
constexpr auto dot(Vector const &a, OtherVector const &b)
Return cross product of two vectors.
Vector_t ComposeVector(Projection_t const &projection) const
Returns the 3D vector from the specified projection.
void ResetNormal()
Reset normal to the plane.
double Angle(Vector_t const &v) const
Returns the angle of the projection from main direction.
typename DecomposedVector_t::Projection_t Projection_t
Type representing the projection vector.
Point_t ReferencePoint() const
Returns the reference point for the plane coordinate, as a 3D point.
Vector rounded01(Vector const &v, Scalar tol)
Returns a vector with all components rounded if close to 0, -1 or +1.
auto mag2(Vector const &v)
Return norm of the specified vector.
typename PlaneDecomposer_t::DecomposedVector_t DecomposedVector_t
Type representing a decomposition on the plane.
typename AffinePlaneBase_t::Vector_t Vector_t
Type for a vector.
auto VectorMainComponent(Vector_t const &v) const
Returns the main component of a vector.
void SetOrigin(Point_t const &point)
Change the 3D point of the reference frame origin.
Vector_t const & SecondaryDir() const
Returns the plane secondary axis direction.
Vector_t const & MainDir() const
Returns the plane main axis direction.
PlaneDecomposer_t fPlaneDecomp
Manages the projection on the plane.
void SetBase(AffinePlaneBase_t &&base)
Change projection base.
auto PointSecondaryComponent(Point_t const &point) const
Returns the secondary component of a point.
Projection_t ProjectVectorOnPlane(Vector_t const &v) const
Returns the projection of the specified vector on the plane.
auto VectorSecondaryComponent(Vector_t const &v) const
Returns the secondary component of a projection vector.
Class with methods for projection of vectors on a plane.
Point_t ReferencePoint() const
Returns the reference point for the plane coordinate, as a 3D point.
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
static constexpr double RoundingTol
Rounding threshold for vectors.
geo::Vector_t Vector_t
Type for the vector in space.
AffinePlaneBase_t fPlaneBase
Reference base.
auto PointMainComponent(Point_t const &point) const
Returns the main component of a 3D point.
void SetMainDir(Vector_t const &dir)
Change the main direction of the projection base.
A base for a plane in space.
Point_t ComposePoint(Projection_t const &projection) const
Returns the 3D point from the specified projection.
ProjVector Projection_t
Type for 2D projection.
Vector_t ComputeNormal() const
Computes the normal to the plane.
Vector_t const & NormalDir() const
Returns the secondary axis direction.
PlaneDecomposer(AffinePlaneBase_t const &base)
Constructor: specifies a base (an origin and two direction vectors)
Vector normalize(Vector const &v)
Returns a vector parallel to v and with norm 1.
void SetSecondaryDir(Vector_t const &dir)
Change the secondary direction of the projection base.
geo::Point_t Point_t
Point in space.
recob::tracking::Plane Plane
typename PlaneDecomposer_t::Point_t Point_t
Type for a vector.
Vector_t const & SecondaryDir() const
Returns the secondary axis direction.
Namespace collecting geometry-related classes utilities.
Vector_t fMain
Main axis on the plane.
recob::tracking::Vector_t Vector_t
Vector_t const & MainDir() const
Returns the main axis direction.
Vector_t const & SecondaryDir() const
Returns the plane secondary axis direction.
constexpr Point origin()
Returns a origin position with a point of the specified type.
typename PlaneDecomposer_t::Vector_t Vector_t
Decomposer(AffinePlaneBase_t const &base)
Constructor: specifies a base (an origin and two direction vectors)
void SetSecondaryDir(Vector_t const &dir)
Change the secondary direction of the projection base.
typename DecomposedVector_t::Distance_t Distance_t
Type representing the signed distance from the projection plane.
void SetMainDir(Vector_t const &dir)
Change the main direction of the projection base.
void SetMainDir(Vector_t const &dir)
Change the main direction of the projection base.