Belle II Software development
Circle2D Class Reference

A two dimensional circle in its natural representation using center and radius as parameters. More...

#include <Circle2D.h>

Public Member Functions

 Circle2D ()
 Default constructor for ROOT compatibility. Creates an invalid circle.
 
 Circle2D (const ROOT::Math::XYVector &center, const double radius)
 Constructs a circle with given center and radius/ orientation as given by the signedRadius.
 
 Circle2D (const ROOT::Math::XYVector &center, const double absRadius, const ERotation ccwInfo)
 Constructs a circle with given center, absolute value of the radius and orientation.
 
void reverse ()
 Flips orientation the circle in place.
 
Circle2D reversed () const
 Returns a copy of the line with the reversed orientation.
 
void conformalTransform ()
 Transforms the circle to conformal space inplace.
 
Circle2D conformalTransformed () const
 Returns a copy of the circle in conformal space.
 
double distance (const ROOT::Math::XYVector &point) const
 Calculates the signed distance of the point to the circle line.
 
double impact () const
 Returns the signed distance to the origin.
 
double absDistance (const ROOT::Math::XYVector &point) const
 Returns the euclidean distance of the point to the circle line.
 
ERightLeft isRightOrLeft (const ROOT::Math::XYVector &point) const
 Return if the point given is right or left of the line.
 
bool isLeft (const ROOT::Math::XYVector &rhs) const
 Return if the point given is left of the circle line.
 
bool isRight (const ROOT::Math::XYVector &rhs) const
 Return if the point given is right of the circle line.
 
ROOT::Math::XYVector closest (const ROOT::Math::XYVector &point) const
 Calculates the point of closest approach on the line to the point.
 
ROOT::Math::XYVector perigee () const
 Returns the point closest to the origin.
 
ROOT::Math::XYVector tangential () const
 Gives the tangential vector at the closest approach to the origin / at the perigee.
 
double tangentialPhi () const
 Gives to azimuth phi of the direction of flight at the perigee.
 
ROOT::Math::XYVector gradient (const ROOT::Math::XYVector &point) const
 Gradient of the distance field.
 
ROOT::Math::XYVector normal (const ROOT::Math::XYVector &point) const
 Normal vector to the circle near the given position.
 
ROOT::Math::XYVector tangential (const ROOT::Math::XYVector &point) const
 Tangential vector to the circle near the given position.
 
double openingAngle (const ROOT::Math::XYVector &from, const ROOT::Math::XYVector &to) const
 Calculates the angle between two points as seen from the center of the circle.
 
double arcLengthBetween (const ROOT::Math::XYVector &from, const ROOT::Math::XYVector &to) const
 Calculates the arc length between two points of closest approach on the circle.
 
double radius () const
 Getter for the signed radius.
 
double radiusSquared () const
 Getter for the squared radius.
 
double absRadius () const
 Getter for the absolute radius.
 
ERotation orientation () const
 Indicates if the circle is to be interpreted counterclockwise or clockwise.
 
ROOT::Math::XYVector center () const
 Getter for the central point of the circle.
 
Transformations of the circle
void moveBy (const ROOT::Math::XYVector &by)
 Actively moves the circle in the direction given in place by the vector given.
 
void moveAlongFirst (const double first)
 Actively moves the circle in the direction given in place along the first coordinate.
 
void moveAlongSecond (const double second)
 Actively moves the circle in the direction given in place along the second coordinate.
 
void passiveMoveBy (const ROOT::Math::XYVector &by)
 Passively move the coordinate system in place by the given vector.
 
void passiveMoveAlongFirst (const double first)
 Passively move the coordinate system in place along the first coordinate.
 
void passiveMoveAlongSecond (const double second)
 Passively move the coordinate system in place along the second coordinate.
 

Private Attributes

ROOT::Math::XYVector m_center
 Memory for the central point.
 
double m_radius
 Memory for the signed radius.
 

Detailed Description

A two dimensional circle in its natural representation using center and radius as parameters.

Definition at line 32 of file Circle2D.h.

Constructor & Destructor Documentation

◆ Circle2D() [1/3]

Circle2D ( )
inline

Default constructor for ROOT compatibility. Creates an invalid circle.

Definition at line 36 of file Circle2D.h.

37 : m_center(0.0, 0.0)
38 , m_radius(0.0)
39 {
40 }

◆ Circle2D() [2/3]

Circle2D ( const ROOT::Math::XYVector & center,
const double radius )
inline

Constructs a circle with given center and radius/ orientation as given by the signedRadius.

Definition at line 43 of file Circle2D.h.

44 : m_center(center)
45 , m_radius(radius)
46 {
47 }

◆ Circle2D() [3/3]

Circle2D ( const ROOT::Math::XYVector & center,
const double absRadius,
const ERotation ccwInfo )
inline

Constructs a circle with given center, absolute value of the radius and orientation.

Definition at line 50 of file Circle2D.h.

51 : m_center(center)
52 , m_radius(fabs(absRadius) * static_cast<double>(ccwInfo))
53 {
54 }

Member Function Documentation

◆ absDistance()

double absDistance ( const ROOT::Math::XYVector & point) const
inline

Returns the euclidean distance of the point to the circle line.

Definition at line 118 of file Circle2D.h.

119 {
120 return fabs(VectorUtil::Distance(center(), point) - absRadius());
121 }

◆ absRadius()

double absRadius ( ) const
inline

Getter for the absolute radius.

Definition at line 219 of file Circle2D.h.

220 {
221 return fabs(radius());
222 }

◆ arcLengthBetween()

double arcLengthBetween ( const ROOT::Math::XYVector & from,
const ROOT::Math::XYVector & to ) const
inline

Calculates the arc length between two points of closest approach on the circle.

Definition at line 201 of file Circle2D.h.

202 {
203 return openingAngle(from, to) * radius();
204 }

◆ center()

ROOT::Math::XYVector center ( ) const
inline

Getter for the central point of the circle.

Definition at line 231 of file Circle2D.h.

232 {
233 return m_center;
234 }

◆ closest()

ROOT::Math::XYVector closest ( const ROOT::Math::XYVector & point) const
inline

Calculates the point of closest approach on the line to the point.

Definition at line 142 of file Circle2D.h.

143 {
144 ROOT::Math::XYVector connection = point - center();
145 if (connection.R() != 0.0) {
146 connection *= (absRadius() / connection.R());
147 }
148 connection += center();
149 return connection;
150 }

◆ conformalTransform()

void conformalTransform ( )
inline

Transforms the circle to conformal space inplace.

Applies the conformal map in the self-inverse from

  • $X = x / (x^2 + y^2 - r^2)$
  • $Y = y / (x^2 + y^2 - r^2)$
  • $R = r / (x^2 + y^2 - r^2)$ inplace This is only stable for off origin circles. The numerical stability of the transformation is subjected to the denominator center().Mag2() - signedRadius() * signedRadius().

Definition at line 80 of file Circle2D.h.

81 {
82 double denominator = 1 / (center().Mag2() - radius() * radius());
83 m_center *= denominator;
84 m_radius *= -denominator;
85 }

◆ conformalTransformed()

Circle2D conformalTransformed ( ) const
inline

Returns a copy of the circle in conformal space.

Applies the conformal map in the self-inverse from

  • $X = x / (x^2 + y^2 - r^2)$
  • $Y = y / (x^2 + y^2 - r^2)$
  • $R = r / (x^2 + y^2 - r^2)$ and returns the result as new Circle2D This is only stable for off origin circles. The numerical stability of the transformation is subjected to the denominator center().Mag2() - signedRadius() * signedRadius().

Definition at line 98 of file Circle2D.h.

99 {
100 double denominator = 1 / (center().Mag2() - radius() * radius());
101 return Circle2D(center() * denominator, -radius() * denominator);
102 }

◆ distance()

double distance ( const ROOT::Math::XYVector & point) const
inline

Calculates the signed distance of the point to the circle line.

Definition at line 106 of file Circle2D.h.

107 {
108 return copysign(VectorUtil::Distance(center(), point), radius()) - radius();
109 }

◆ gradient()

ROOT::Math::XYVector gradient ( const ROOT::Math::XYVector & point) const
inline

Gradient of the distance field.

Definition at line 176 of file Circle2D.h.

177 {
178 ROOT::Math::XYVector connection = (point - center()) * orientation();
179 return VectorUtil::unit(connection);
180 }

◆ impact()

double impact ( ) const
inline

Returns the signed distance to the origin.

Definition at line 112 of file Circle2D.h.

113 {
114 return copysign(center().R(), radius()) - radius();
115 }
double R
typedef autogenerated by FFTW

◆ isLeft()

bool isLeft ( const ROOT::Math::XYVector & rhs) const
inline

Return if the point given is left of the circle line.

Definition at line 130 of file Circle2D.h.

131 {
132 return isRightOrLeft(rhs) == ERightLeft::c_Left;
133 }

◆ isRight()

bool isRight ( const ROOT::Math::XYVector & rhs) const
inline

Return if the point given is right of the circle line.

Definition at line 136 of file Circle2D.h.

137 {
138 return isRightOrLeft(rhs) == ERightLeft::c_Right;
139 }

◆ isRightOrLeft()

ERightLeft isRightOrLeft ( const ROOT::Math::XYVector & point) const
inline

Return if the point given is right or left of the line.

Definition at line 124 of file Circle2D.h.

125 {
126 return static_cast<ERightLeft>(sign(distance(point)));
127 }
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition ERightLeft.h:25

◆ moveAlongFirst()

void moveAlongFirst ( const double first)
inline

Actively moves the circle in the direction given in place along the first coordinate.

Definition at line 245 of file Circle2D.h.

246 {
247 m_center.SetX(m_center.X() + first);
248 }

◆ moveAlongSecond()

void moveAlongSecond ( const double second)
inline

Actively moves the circle in the direction given in place along the second coordinate.

Definition at line 251 of file Circle2D.h.

252 {
253 m_center.SetY(m_center.Y() + second);
254 }

◆ moveBy()

void moveBy ( const ROOT::Math::XYVector & by)
inline

Actively moves the circle in the direction given in place by the vector given.

Definition at line 239 of file Circle2D.h.

240 {
241 m_center += by;
242 }

◆ normal()

ROOT::Math::XYVector normal ( const ROOT::Math::XYVector & point) const
inline

Normal vector to the circle near the given position.

Definition at line 183 of file Circle2D.h.

184 {
185 return VectorUtil::unit(gradient(point));
186 }

◆ openingAngle()

double openingAngle ( const ROOT::Math::XYVector & from,
const ROOT::Math::XYVector & to ) const
inline

Calculates the angle between two points as seen from the center of the circle.

Definition at line 195 of file Circle2D.h.

196 {
197 return ROOT::Math::VectorUtil::DeltaPhi(gradient(from), gradient(to));
198 } // can be optimized in the number of computations

◆ orientation()

ERotation orientation ( ) const
inline

Indicates if the circle is to be interpreted counterclockwise or clockwise.

Definition at line 225 of file Circle2D.h.

226 {
227 return static_cast<ERotation>(sign(radius()));
228 }
ERotation
Enumeration to represent the distinct possibilities of the right left passage information.
Definition ERotation.h:25

◆ passiveMoveAlongFirst()

void passiveMoveAlongFirst ( const double first)
inline

Passively move the coordinate system in place along the first coordinate.

Definition at line 263 of file Circle2D.h.

264 {
265 m_center.SetX(m_center.X() - first);
266 }

◆ passiveMoveAlongSecond()

void passiveMoveAlongSecond ( const double second)
inline

Passively move the coordinate system in place along the second coordinate.

Definition at line 269 of file Circle2D.h.

270 {
271 m_center.SetY(m_center.Y() - second);
272 }

◆ passiveMoveBy()

void passiveMoveBy ( const ROOT::Math::XYVector & by)
inline

Passively move the coordinate system in place by the given vector.

Definition at line 257 of file Circle2D.h.

258 {
259 m_center -= by;
260 }

◆ perigee()

ROOT::Math::XYVector perigee ( ) const
inline

Returns the point closest to the origin.

Definition at line 153 of file Circle2D.h.

154 {
155 ROOT::Math::XYVector connection = center();
156 if (connection.R() != 0.0) {
157 connection *= (-absRadius() / connection.R());
158 }
159 connection += center();
160 return connection;
161 }

◆ radius()

double radius ( ) const
inline

Getter for the signed radius.

Definition at line 207 of file Circle2D.h.

208 {
209 return m_radius;
210 }

◆ radiusSquared()

double radiusSquared ( ) const
inline

Getter for the squared radius.

Definition at line 213 of file Circle2D.h.

214 {
215 return radius() * radius();
216 }

◆ reverse()

void reverse ( )
inline

Flips orientation the circle in place.

Definition at line 58 of file Circle2D.h.

59 {
60 m_radius *= -1;
61 }

◆ reversed()

Circle2D reversed ( ) const
inline

Returns a copy of the line with the reversed orientation.

Definition at line 64 of file Circle2D.h.

65 {
66 return Circle2D(center(), -radius());
67 }

◆ tangential() [1/2]

ROOT::Math::XYVector tangential ( ) const
inline

Gives the tangential vector at the closest approach to the origin / at the perigee.

Definition at line 164 of file Circle2D.h.

165 {
166 return VectorUtil::unit(tangential(ROOT::Math::XYVector(0.0, 0.0)));
167 }

◆ tangential() [2/2]

ROOT::Math::XYVector tangential ( const ROOT::Math::XYVector & point) const
inline

Tangential vector to the circle near the given position.

Definition at line 189 of file Circle2D.h.

190 {
191 return VectorUtil::Orthogonal(normal(point));
192 }

◆ tangentialPhi()

double tangentialPhi ( ) const
inline

Gives to azimuth phi of the direction of flight at the perigee.

Definition at line 170 of file Circle2D.h.

171 {
172 return tangential().Phi();
173 }

Member Data Documentation

◆ m_center

ROOT::Math::XYVector m_center
private

Memory for the central point.

Definition at line 277 of file Circle2D.h.

◆ m_radius

double m_radius
private

Memory for the signed radius.

Definition at line 280 of file Circle2D.h.


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