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 Vector2D &center, const double radius)
 Constructs a circle with given center and radius/ orientation as given by the signedRadius.
 
 Circle2D (const Vector2D &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 Vector2D &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 Vector2D &point) const
 Returns the euclidean distance of the point to the circle line.
 
ERightLeft isRightOrLeft (const Vector2D &point) const
 Return if the point given is right or left of the line.
 
bool isLeft (const Vector2D &rhs) const
 Return if the point given is left of the circle line.
 
bool isRight (const Vector2D &rhs) const
 Return if the point given is right of the circle line.
 
Vector2D closest (const Vector2D &point) const
 Calculates the point of closest approach on the line to the point.
 
Vector2D perigee () const
 Returns the point closest to the origin.
 
Vector2D 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.
 
Vector2D gradient (const Vector2D &point) const
 Gradient of the distance field.
 
Vector2D normal (const Vector2D &point) const
 Normal vector to the circle near the given position.
 
Vector2D tangential (const Vector2D &point) const
 Tangential vector to the circle near the given position.
 
double openingAngle (const Vector2D &from, const Vector2D &to) const
 Calculates the angle between two points as seen from the center of the circle.
 
double arcLengthBetween (const Vector2D &from, const Vector2D &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.
 
Vector2D center () const
 Getter for the central point of the circle.
 
Transformations of the circle
void moveBy (const Vector2D &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 Vector2D &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

Vector2D 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 26 of file Circle2D.h.

Constructor & Destructor Documentation

◆ Circle2D() [1/3]

Circle2D ( )
inline

Default constructor for ROOT compatibility. Creates an invalid circle.

Definition at line 30 of file Circle2D.h.

31 : m_center(0.0, 0.0)
32 , m_radius(0.0)
33 {
34 }

◆ Circle2D() [2/3]

Circle2D ( const Vector2D & center,
const double radius )
inline

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

Definition at line 37 of file Circle2D.h.

38 : m_center(center)
39 , m_radius(radius)
40 {
41 }

◆ Circle2D() [3/3]

Circle2D ( const Vector2D & center,
const double absRadius,
const ERotation ccwInfo )
inline

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

Definition at line 44 of file Circle2D.h.

45 : m_center(center)
46 , m_radius(fabs(absRadius) * static_cast<double>(ccwInfo))
47 {
48 }

Member Function Documentation

◆ absDistance()

double absDistance ( const Vector2D & point) const
inline

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

Definition at line 112 of file Circle2D.h.

113 {
114 return fabs(center().distance(point) - absRadius());
115 }

◆ absRadius()

double absRadius ( ) const
inline

Getter for the absolute radius.

Definition at line 209 of file Circle2D.h.

210 {
211 return fabs(radius());
212 }

◆ arcLengthBetween()

double arcLengthBetween ( const Vector2D & from,
const Vector2D & to ) const
inline

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

Definition at line 191 of file Circle2D.h.

192 {
193 return openingAngle(from, to) * radius();
194 }

◆ center()

Vector2D center ( ) const
inline

Getter for the central point of the circle.

Definition at line 221 of file Circle2D.h.

222 {
223 return m_center;
224 }

◆ closest()

Vector2D closest ( const Vector2D & point) const
inline

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

Definition at line 136 of file Circle2D.h.

137 {
138 Vector2D connection = point - center();
139 connection.normalizeTo(absRadius());
140 connection += center();
141 return connection;
142 }

◆ 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().normSquared() - signedRadius() * signedRadius().

Definition at line 74 of file Circle2D.h.

75 {
76 double denominator = 1 / (center().normSquared() - radius() * radius());
77 m_center *= denominator;
78 m_radius *= -denominator;
79 }

◆ 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().normSquared() - signedRadius() * signedRadius().

Definition at line 92 of file Circle2D.h.

93 {
94 double denominator = 1 / (center().normSquared() - radius() * radius());
95 return Circle2D(center() * denominator, -radius() * denominator);
96 }

◆ distance()

double distance ( const Vector2D & point) const
inline

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

Definition at line 100 of file Circle2D.h.

101 {
102 return copysign(center().distance(point), radius()) - radius();
103 }

◆ gradient()

Vector2D gradient ( const Vector2D & point) const
inline

Gradient of the distance field.

Definition at line 166 of file Circle2D.h.

167 {
168 Vector2D connection = (point - center()) * orientation();
169 return connection.unit();
170 }

◆ impact()

double impact ( ) const
inline

Returns the signed distance to the origin.

Definition at line 106 of file Circle2D.h.

107 {
108 return copysign(center().norm(), radius()) - radius();
109 }

◆ isLeft()

bool isLeft ( const Vector2D & rhs) const
inline

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

Definition at line 124 of file Circle2D.h.

125 {
126 return isRightOrLeft(rhs) == ERightLeft::c_Left;
127 }

◆ isRight()

bool isRight ( const Vector2D & rhs) const
inline

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

Definition at line 130 of file Circle2D.h.

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

◆ isRightOrLeft()

ERightLeft isRightOrLeft ( const Vector2D & point) const
inline

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

Definition at line 118 of file Circle2D.h.

119 {
120 return static_cast<ERightLeft>(sign(distance(point)));
121 }
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 235 of file Circle2D.h.

236 {
237 m_center.setFirst(m_center.first() + first);
238 }

◆ moveAlongSecond()

void moveAlongSecond ( const double second)
inline

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

Definition at line 241 of file Circle2D.h.

242 {
243 m_center.setSecond(m_center.second() + second);
244 }

◆ moveBy()

void moveBy ( const Vector2D & by)
inline

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

Definition at line 229 of file Circle2D.h.

230 {
231 m_center += by;
232 }

◆ normal()

Vector2D normal ( const Vector2D & point) const
inline

Normal vector to the circle near the given position.

Definition at line 173 of file Circle2D.h.

174 {
175 return gradient(point).unit();
176 }

◆ openingAngle()

double openingAngle ( const Vector2D & from,
const Vector2D & to ) const
inline

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

Definition at line 185 of file Circle2D.h.

186 {
187 return gradient(from).angleWith(gradient(to));
188 } // 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 215 of file Circle2D.h.

216 {
217 return static_cast<ERotation>(sign(radius()));
218 }
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 253 of file Circle2D.h.

254 {
255 m_center.setFirst(m_center.first() - first);
256 }

◆ passiveMoveAlongSecond()

void passiveMoveAlongSecond ( const double second)
inline

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

Definition at line 259 of file Circle2D.h.

260 {
261 m_center.setSecond(m_center.second() - second);
262 }

◆ passiveMoveBy()

void passiveMoveBy ( const Vector2D & by)
inline

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

Definition at line 247 of file Circle2D.h.

248 {
249 m_center -= by;
250 }

◆ perigee()

Vector2D perigee ( ) const
inline

Returns the point closest to the origin.

Definition at line 145 of file Circle2D.h.

146 {
147 Vector2D connection = center();
148 connection.normalizeTo(-absRadius());
149 connection += center();
150 return connection;
151 }

◆ radius()

double radius ( ) const
inline

Getter for the signed radius.

Definition at line 197 of file Circle2D.h.

198 {
199 return m_radius;
200 }

◆ radiusSquared()

double radiusSquared ( ) const
inline

Getter for the squared radius.

Definition at line 203 of file Circle2D.h.

204 {
205 return radius() * radius();
206 }

◆ reverse()

void reverse ( )
inline

Flips orientation the circle in place.

Definition at line 52 of file Circle2D.h.

53 {
54 m_radius *= -1;
55 }

◆ reversed()

Circle2D reversed ( ) const
inline

Returns a copy of the line with the reversed orientation.

Definition at line 58 of file Circle2D.h.

59 {
60 return Circle2D(center(), -radius());
61 }

◆ tangential() [1/2]

Vector2D tangential ( ) const
inline

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

Definition at line 154 of file Circle2D.h.

155 {
156 return tangential(Vector2D(0.0, 0.0)).unit();
157 }

◆ tangential() [2/2]

Vector2D tangential ( const Vector2D & point) const
inline

Tangential vector to the circle near the given position.

Definition at line 179 of file Circle2D.h.

180 {
181 return normal(point).orthogonal();
182 }

◆ tangentialPhi()

double tangentialPhi ( ) const
inline

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

Definition at line 160 of file Circle2D.h.

161 {
162 return tangential().phi();
163 }

Member Data Documentation

◆ m_center

Vector2D m_center
private

Memory for the central point.

Definition at line 267 of file Circle2D.h.

◆ m_radius

double m_radius
private

Memory for the signed radius.

Definition at line 270 of file Circle2D.h.


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