ATLAS Offline Software
Loading...
Searching...
No Matches
MuonR4::Circle Class Reference

Auxiliary class to construct a circle from three arbitrary points in space. More...

#include <Circle.h>

Collaboration diagram for MuonR4::Circle:

Public Member Functions

 Circle (const Amg::Vector3D &pointA, const Amg::Vector3D &pointB, const Amg::Vector3D &pointC)
 Constructor taking three points in a plane If points are on a line, the plane is set to be the null vector.
const Amg::Vector3Dcenter () const
 The center point of the circle.
const Amg::Vector3Dnormal () const
 The vector that is normal to the circle.
double radius () const
 The radius of the circle.

Private Member Functions

std::ostream & print (std::ostream &ostr) const

Private Attributes

Amg::Vector3D m_center {Amg::Vector3D::Zero()}
 The center point of the circle.
Amg::Vector3D m_normal {Amg::Vector3D::Zero()}
 The plane normal of the circle.
double m_radius {0.}
 The radius of the circle.

Friends

std::ostream & operator<< (std::ostream &ostr, const Circle &circ)
 Define the ostream operator.

Detailed Description

Auxiliary class to construct a circle from three arbitrary points in space.

The center point, (signed) radius and the normal vector to the plane spanned by the points are evaluated.

Definition at line 15 of file Circle.h.

Constructor & Destructor Documentation

◆ Circle()

MuonR4::Circle::Circle ( const Amg::Vector3D & pointA,
const Amg::Vector3D & pointB,
const Amg::Vector3D & pointC )
explicit

Constructor taking three points in a plane If points are on a line, the plane is set to be the null vector.

Parameters
pointAFirst circle point
pointBSecond circle point
pointCThird circle point

Construct the connection line A -> C

Construct the connection line A -> B

The circle plane normal is the normalized cross product between the 2

Calculate the bisector between A + B

Calculate the bisector between A + C

Definition at line 16 of file Circle.cxx.

18 {
19
21 const Amg::Vector3D AC = (pointC - pointA).unit();
23 const Amg::Vector3D AB = (pointB - pointA).unit();
25 m_normal = AC.cross(AB).unit();
27 const Amg::Vector3D midAB = 0.5*(pointA + pointB);
29 const Amg::Vector3D midAC = 0.5*(pointA + pointC);
30
31 const Amg::Vector3D normAB = AB.cross(m_normal);
32 const Amg::Vector3D normAC = AC.cross(m_normal);
33
34 const std::optional<double> midIsect = Amg::intersect<3>(midAB, normAB, midAC, normAC);
35 if (!midIsect) {
36 m_normal.setZero();
37 return;
38 }
39 m_center = midAC + (*midIsect) * normAC;
40 m_radius = std::copysign((pointA - m_center).mag(), (*midIsect));
41 }
Scalar mag() const
mag method
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
double m_radius
The radius of the circle.
Definition Circle.h:44
Amg::Vector3D m_center
The center point of the circle.
Definition Circle.h:40
Amg::Vector3D m_normal
The plane normal of the circle.
Definition Circle.h:42
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point B' along the line B that's closest to a second line A.
Eigen::Matrix< double, 3, 1 > Vector3D

Member Function Documentation

◆ center()

const Amg::Vector3D & MuonR4::Circle::center ( ) const
inline

The center point of the circle.

Definition at line 28 of file Circle.h.

28{ return m_center; }

◆ normal()

const Amg::Vector3D & MuonR4::Circle::normal ( ) const
inline

The vector that is normal to the circle.

Definition at line 30 of file Circle.h.

30{ return m_normal; }

◆ print()

std::ostream & MuonR4::Circle::print ( std::ostream & ostr) const
private

Definition at line 10 of file Circle.cxx.

10 {
11 ostr<<"Circle - center: "<<Amg::toString(center())
12 <<", radius: "<<radius()
13 <<", normal: "<<Amg::toString(normal());
14 return ostr;
15 }
const Amg::Vector3D & center() const
The center point of the circle.
Definition Circle.h:28
const Amg::Vector3D & normal() const
The vector that is normal to the circle.
Definition Circle.h:30
double radius() const
The radius of the circle.
Definition Circle.h:32
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.

◆ radius()

double MuonR4::Circle::radius ( ) const
inline

The radius of the circle.

Definition at line 32 of file Circle.h.

32{ return m_radius; }

◆ operator<<

std::ostream & operator<< ( std::ostream & ostr,
const Circle & circ )
friend

Define the ostream operator.

Definition at line 34 of file Circle.h.

34 {
35 return circ.print(ostr);
36 }

Member Data Documentation

◆ m_center

Amg::Vector3D MuonR4::Circle::m_center {Amg::Vector3D::Zero()}
private

The center point of the circle.

Definition at line 40 of file Circle.h.

40{Amg::Vector3D::Zero()};

◆ m_normal

Amg::Vector3D MuonR4::Circle::m_normal {Amg::Vector3D::Zero()}
private

The plane normal of the circle.

Definition at line 42 of file Circle.h.

42{Amg::Vector3D::Zero()};

◆ m_radius

double MuonR4::Circle::m_radius {0.}
private

The radius of the circle.

Definition at line 44 of file Circle.h.

44{0.};

The documentation for this class was generated from the following files: