|
ATLAS Offline Software
|
Go to the documentation of this file.
9 #ifndef GEOPRIMITIVES_GEOPRIMITIVESHELPERS_H
10 #define GEOPRIMITIVES_GEOPRIMITIVESHELPERS_H
35 using SetVector3D = std::set<Amg::Vector3D, Vector3DComparer>;
42 const double dp = std::clamp(v1.dot(
v2) / (v1.mag() *
v2.mag()), -1. ,1.);
114 double dphi =
v2.phi() - v1.phi();
117 }
else if (dphi <= -
M_PI) {
123 double a = v1.eta() -
v2.eta();
125 return sqrt(
a*
a +
b*
b);
158 double vx =
v.x(), vy =
v.y(), vz =
v.z();
160 tr(0,0)*vx + tr(0,1)*vy + tr(0,2)*vz + tr(0,3),
161 tr(1,0)*vx + tr(1,1)*vy + tr(1,2)*vz + tr(1,3),
162 tr(2,0)*vx + tr(2,1)*vy + tr(2,2)*vz + tr(2,3));
176 trans.translation() = transl_vec;
200 double cosa = 0.5 * (xx +
yy + zz - 1);
201 double cosa1 = 1 - cosa;
208 double x=0,
y=0,
z=0;
209 if (xx > cosa)
x = std::sqrt((xx-cosa)/cosa1);
210 if (
yy > cosa)
y = std::sqrt((
yy-cosa)/cosa1);
211 if (zz > cosa)
z = std::sqrt((zz-cosa)/cosa1);
215 rotationAngle = (cosa < -1.) ? std::acos(-1.) : std::acos(cosa);
308 const double dirDots = dirA.dot(dirB);
309 const double divisor = (1. - dirDots * dirDots);
311 if (std::abs(
divisor) < std::numeric_limits<double>::epsilon()) {
312 const AmgVector(
N)
d = posA + dirA.dot(AminusB)*dirA;
313 return std::sqrt(
d.dot(
d));
315 const AmgVector(
N) lineTravel = AminusB.dot(dirA) * dirA -
316 AminusB.dot(dirB) * dirB;
317 return std::sqrt(
std::max(0., AminusB.dot(AminusB) - lineTravel.dot(lineTravel)) /
divisor);
337 const double dirDots = dirA.dot(dirB);
338 const double divisor = (1. - dirDots * dirDots);
340 if (std::abs(
divisor) < std::numeric_limits<double>::epsilon())
return std::nullopt;
342 return (AminusB.dot(dirB) - AminusB.dot(dirA) * dirDots) /
divisor;
354 const double normDot = planeNorm.dot(
dir);
355 if (std::abs(normDot) < std::numeric_limits<double>::epsilon())
return std::nullopt;
356 return (
offset -
pos.dot(planeNorm)) / normDot;
362 for (
unsigned int d = 0;
d < 3 ; ++
d) {
363 const double defLength = Amg::Vector3D::Unit(
d).dot(trans.linear() * Amg::Vector3D::Unit(
d));
364 if (std::abs(defLength - 1.) > std::numeric_limits<float>::epsilon()) {
373 trans.translation().mag() < std::numeric_limits<float>::epsilon();
Eigen::Quaternion< double > Rotation3D
void setMag(Amg::Vector3D &v, double mag)
scales the vector length without changing the angles
double angle(const Amg::Vector3D &v1, const Amg::Vector3D &v2)
calculates the opening angle between two vectors
Scalar perp() const
perp method - perpenticular length
double deltaPhi(const Amg::Vector3D &v1, const Amg::Vector3D &v2)
Amg::Transform3D getTranslateZ3D(const double Z)
: Returns a shift transformation along the z-axis
Helper to simultaneously calculate sin and cos of the same angle.
Amg::Transform3D getTranslateY3D(const double Y)
: Returns a shift transformation along the y-axis
void getAngleAxisFromRotation(Amg::RotationMatrix3D &rotation, double &rotationAngle, Amg::Vector3D &rotationAxis)
std::set< std::vector< Amg::Vector3D >, VectorVector3DComparer > SetVectorVector3D
Amg::RotationMatrix3D setPhi(Amg::RotationMatrix3D mat, double angle, int convention=0)
Amg::Transform3D getRotateZ3D(double angle)
get a rotation transformation around Z-axis
double rVector3D(const Amg::Vector3D &v1)
Gets r-component in spherical coordinate system.
Amg::Transform3D getTransformFromRotTransl(Amg::RotationMatrix3D rot, Amg::Vector3D transl_vec)
Amg::Transform3D getRotateX3D(double angle)
get a rotation transformation around X-axis
Amg::Vector3D getTranslationVectorFromTransform(const Amg::Transform3D &tr)
Get the Translation vector out of a Transformation.
Amg::Rotation3D getRotation3DfromAngleAxis(double angle, Amg::Vector3D &axis)
get a AngleAxis from an angle and an axis.
Eigen::Affine3d Transform3D
bool doesNotDeform(const Amg::Transform3D &trans)
Checks whether the linear part of the transformation rotates or stetches any of the basis vectors.
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
void setVector3DCartesian(Amg::Vector3D &v1, double x1, double y1, double z1)
Sets components in cartesian coordinate system.
bool isIdentity(const Amg::Transform3D &trans)
Checks whether the transformation is the Identity transformation.
void setPerp(Amg::Vector3D &v, double perp)
scales the vector in the xy plane without changing the z coordinate nor the angles
Definition of ATLAS Math & Geometry primitives (Amg)
void setTheta(Amg::Vector3D &v, double theta)
sets the theta of a vector without changing phi nor the magnitude
double lineDistance(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the shortest distance between two lines posA: offset point of line A dirA: orientation of ...
Amg::Transform3D getRotateY3D(double angle)
get a rotation transformation around Y-axis
Eigen::Matrix< double, 3, 1 > Vector3D
double mag2Vector3D(const Amg::Vector3D &v1)
Gets magnitude squared of the vector.
double deltaR(const Amg::Vector3D &v1, const Amg::Vector3D &v2)
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point of closest approach of two lines.
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Eigen::Translation< double, 3 > Translation3D
void setRThetaPhi(Amg::Vector3D &v, double r, double theta, double phi)
sets radius, the theta and phi angle of a vector.
Helper to simultaneously calculate sin and cos of the same angle.
Eigen::AngleAxisd AngleAxis3D
float distance2(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the squared distance between two point in 3D space
double magVector3D(const Amg::Vector3D &v1)
Gets magnitude of the vector.
std::set< Amg::Vector3D, Vector3DComparer > SetVector3D
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Amg::Transform3D getTranslateX3D(const double X)
: Returns a shift transformation along the x-axis
Scalar mag() const
mag method
void setThetaPhi(Amg::Vector3D &v, double theta, double phi)
sets the theta and phi angle of a vector without changing the magnitude
Amg::Transform3D getTranslate3D(const double X, const double Y, const double Z)
: Returns a shift transformation along an arbitrary axis