10 #ifndef LARCOREALG_GEOMETRY_DECOMPOSER_H 11 #define LARCOREALG_GEOMETRY_DECOMPOSER_H 19 #include <type_traits> 38 template <
typename Vector>
92 template <
typename Vector,
typename Po
int = Vector>
104 , fBase(main, secondary)
142 template <
typename ProjVector>
158 : projection(projection), distance(distance) {}
161 : projection(projection), distance(distance) {}
178 template <
typename Vector,
typename Po
int,
typename ProjVector>
233 { fPlaneBase.SetSecondaryDir(dir); }
275 {
return VectorMainComponent(
Base().ToVector(point)); }
279 {
return VectorSecondaryComponent(
Base().ToVector(point)); }
293 {
return VectorProjection(
Base().ToVector(point)); }
315 {
return { VectorMainComponent(v), VectorSecondaryComponent(v) }; }
331 = std::atan2(VectorSecondaryComponent(v), VectorMainComponent(v));
353 return MainComponent(projection) *
MainDir()
370 {
return ReferencePoint() + ComposeVector(projection); }
390 template <
typename Vector,
typename Po
int,
typename ProjVector>
438 { fPlaneDecomp.
SetBase(base); }
479 {
return VectorMainComponent(
Base().ToVector(point)); }
483 {
return VectorSecondaryComponent(
Base().ToVector(point)); }
487 {
return VectorNormalComponent(
Base().ToVector(point)); }
501 {
return Plane().PointProjection(point); }
518 {
return DecomposeVector(
Base().ToVector(point)); }
528 {
return Plane().VectorMainComponent(v); }
532 {
return Plane().VectorSecondaryComponent(v); }
550 {
return Plane().VectorProjection(v); }
567 {
return { VectorNormalComponent(v), ProjectVectorOnPlane(v) }; }
581 {
return Plane().Angle(v); }
591 {
return Plane().MainComponent(v); }
595 {
return Plane().SecondaryComponent(v); }
612 {
return ComposePoint(decomp.distance, decomp.projection); }
633 {
return ReferencePoint() + ComposeVector(distance, proj); }
649 {
return ComposeVector(decomp.distance, decomp.projection); }
683 #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.
Utilities to extend the interface of geometry vectors.
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.
constexpr auto dot(Vector const &a, Vector const &b)
Return cross product of two vectors.
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.
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.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >> Point_t
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.
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.
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
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)
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.
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
void SetBase(AffinePlaneBase_t const &base)
Change projection base.
void SetOrigin(Point_t const &point)
Change the 3D point of the reference frame origin.
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.
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.
LArSoft geometry interface.
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.