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>
226 void SetOrigin(
Point_t const& point) { fPlaneBase.SetOrigin(point); }
229 void SetMainDir(
Vector_t const&
dir) { fPlaneBase.SetMainDir(dir); }
232 void SetSecondaryDir(
Vector_t const& dir)
233 { fPlaneBase.SetSecondaryDir(dir); }
241 Point_t ReferencePoint()
const {
return Base().Origin(); }
244 Vector_t const& MainDir()
const {
return Base().MainDir(); }
247 Vector_t const& SecondaryDir()
const {
return Base().SecondaryDir(); }
262 auto MainComponent(
Projection_t const& v)
const {
return v.X(); }
265 auto SecondaryComponent(
Projection_t const& v)
const {
return v.Y(); }
274 auto PointMainComponent(
Point_t const& point)
const
275 {
return VectorMainComponent(Base().ToVector(point)); }
278 auto PointSecondaryComponent(
Point_t const& point)
const
279 {
return VectorSecondaryComponent(Base().ToVector(point)); }
293 {
return VectorProjection(Base().ToVector(point)); }
297 auto VectorMainComponent(
Vector_t const& v)
const
301 auto VectorSecondaryComponent(
Vector_t const& v)
const
315 {
return { VectorMainComponent(v), VectorSecondaryComponent(v) }; }
328 double Angle(
Vector_t const& v)
const
331 = std::atan2(VectorSecondaryComponent(v), VectorMainComponent(v));
332 return (a >= M_PI)? -M_PI:
a;
353 return MainComponent(projection) * MainDir()
354 + SecondaryComponent(projection) * SecondaryDir()
370 {
return ReferencePoint() + ComposeVector(projection); }
390 template <
typename Vector,
typename Po
int,
typename ProjVector>
501 {
return Plane().PointProjection(point); }
528 {
return Plane().VectorMainComponent(v); }
532 {
return Plane().VectorSecondaryComponent(v); }
550 {
return Plane().VectorProjection(v); }
581 {
return Plane().Angle(v); }
591 {
return Plane().MainComponent(v); }
595 {
return Plane().SecondaryComponent(v); }
612 {
return ComposePoint(decomp.distance, decomp.projection); }
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.
auto VectorSecondaryComponent(Vector_t const &v) const
Returns the secondary component of a vector.
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
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.
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.
Vector_t ToVector(Point_t const &point) const
Returns the vector representing the specified point in the affine space.
Decomposer()=default
Default constructor: projection on (x,y) with origin (0, 0, 0)
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.
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.
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.
DecomposedVector(Distance_t distance, Projection_t const &projection)
auto VectorNormalComponent(Vector_t const &v) const
Returns the secondary component of a vector.
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 SecondaryComponent(Projection_t const &v) const
Returns the secondary component of a projection vector.
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
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)
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.
void SetBase(AffinePlaneBase_t const &base)
Change projection base.
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.
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.
DecomposedVector()=default
DecomposedVector< ProjVector > DecomposedVector_t
Type of decomposed vector.
Class with methods for projection of vectors on a plane.
static constexpr double RoundingTol
Rounding threshold for vectors.
Vector Vector_t
Type for the vector in space.
void SetMainDir(Vector_t const &dir)
Change the main direction of the projection base.
A base for a plane in space.
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.
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.
Point Point_t
Point in space.
int main(int argc, char **argv)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
typename PlaneDecomposer_t::Point_t Point_t
Type for a vector.
Vector_t const & SecondaryDir() const
Returns the secondary axis direction.
Vector_t fMain
Main axis on the plane.
recob::tracking::Vector_t Vector_t
Vector_t const & MainDir() const
Returns the main 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.
AffinePlaneBase< Vector, Point > AffinePlaneBase_t