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, absolut 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 euclidian 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)
 Activelly moves the circle in the direction given in place by the vector given.
 
void moveAlongFirst (const double first)
 Activelly moves the circle in the direction given in place along the first coordinate.
 
void moveAlongSecond (const double second)
 Activelly moves the circle in the direction given in place along the second coordinate.
 
void passiveMoveBy (const Vector2D &by)
 Passivelly move the coordinate system in place by the given vector.
 
void passiveMoveAlongFirst (const double first)
 Passivelly move the coordinate system in place along the first coordinate.
 
void passiveMoveAlongSecond (const double second)
 Passivelly 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 }
double m_radius
Memory for the signed radius.
Definition: Circle2D.h:270
Vector2D m_center
Memory for the central point.
Definition: Circle2D.h:267

◆ 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.

40 {
41 }
double radius() const
Getter for the signed radius.
Definition: Circle2D.h:197
Vector2D center() const
Getter for the central point of the circle.
Definition: Circle2D.h:221

◆ Circle2D() [3/3]

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

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

Definition at line 44 of file Circle2D.h.

46 , m_radius(fabs(absRadius) * static_cast<double>(ccwInfo))
47 {
48 }
double absRadius() const
Getter for the absolute radius.
Definition: Circle2D.h:209

Member Function Documentation

◆ absDistance()

double absDistance ( const Vector2D point) const
inline

Returns the euclidian 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 }
double distance(const Vector2D &point) const
Calculates the signed distance of the point to the circle line.
Definition: Circle2D.h:100

◆ 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 }
double openingAngle(const Vector2D &from, const Vector2D &to) const
Calculates the angle between two points as seen from the center of the circle.
Definition: Circle2D.h:185

◆ 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 }
double normSquared() const
Calculates .
Definition: Vector2D.h:169

◆ 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 }
Circle2D()
Default constructor for ROOT compatibility. Creates an invalid circle.
Definition: Circle2D.h:30

◆ 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 }
ERotation orientation() const
Indicates if the circle is to be interpreted counterclockwise or clockwise.
Definition: Circle2D.h:215

◆ 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 }
ERightLeft isRightOrLeft(const Vector2D &point) const
Return if the point given is right or left of the line.
Definition: Circle2D.h:118

◆ 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

Activelly 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 }
double first() const
Getter for the first coordinate.
Definition: Vector2D.h:629
void setFirst(const double first)
Setter for the first coordinate.
Definition: Vector2D.h:634

◆ moveAlongSecond()

void moveAlongSecond ( const double  second)
inline

Activelly 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 }
void setSecond(const double second)
Setter for the second coordinate.
Definition: Vector2D.h:644
double second() const
Getter for the second coordinate.
Definition: Vector2D.h:639

◆ moveBy()

void moveBy ( const Vector2D by)
inline

Activelly 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 }
Vector2D gradient(const Vector2D &point) const
Gradient of the distance field.
Definition: Circle2D.h:166
Vector2D unit() const
Returns a unit vector colaligned with this.
Definition: Vector2D.h:321

◆ 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
double angleWith(const Vector2D &rhs) const
The angle between this and rhs.
Definition: Vector2D.h:197

◆ 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

Passivelly 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

Passivelly 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

Passivelly 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 }
Vector2D tangential() const
Gives the tangential vector at the closest approach to the origin / at the perigee.
Definition: Circle2D.h:154

◆ 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 }
Vector2D normal(const Vector2D &point) const
Normal vector to the circle near the given position.
Definition: Circle2D.h:173
Vector2D orthogonal() const
Orthogonal vector to the counterclockwise direction.
Definition: Vector2D.h:289

◆ 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 }
double phi() const
Gives the azimuth angle being the angle to the x axes ( range -M_PI to M_PI )
Definition: Vector2D.h:569

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: