Belle II Software development
|
A two dimensional normal line. More...
#include <Line2D.h>
Public Member Functions | |
Line2D () | |
Default constructor for ROOT compatibility. | |
Line2D (const double n0, const double n1, const double n2) | |
Constructs taking all three line parameters. | |
Line2D (const double n0, const Vector2D &n12) | |
Constructs taking the distance to the origin ( n0 ) and the normal vector. | |
double | n0 () const |
Getter for the first line parameter. | |
double | n1 () const |
Getter for the second line parameter. | |
double | n2 () const |
Getter for the third line parameter. | |
const Vector2D & | n12 () const |
Getter for the unit normal vector to the line. | |
void | setN0 (const double n0) |
Setter for first line parameter This sets the signed distance of the line to the origin. | |
void | setN (const double n0, const double n1, const double n2) |
Setter the for the line parameters which takes care of the correct normalization of the normal vector. | |
void | invalidate () |
Sets all line parameters to zero. | |
void | setSlopeIntercept (const double slope, const double intercept) |
Sets the new intercept and slope of the line the direction is set to be forward with the increasing x axes. | |
void | setSlopeIntercept (const double slope, const double intercept, const EForwardBackward orientation) |
Sets the new intercept and slope of the line the direction is set to be forward with the increasing x axes. | |
void | normalize () |
Updates the parameters to obey the normalization condition. | |
void | reverse () |
Flips orientation the line in place. | |
Line2D | reversed () const |
Returns a copy of the line with the reversed orientation. | |
double | distance (const Vector2D &point) const |
Calculates the signed distance of the point to the line. | |
double | distance (const double first, const double second) const |
Calculates the signed distance of the point given by its to coordinates to the line. | |
double | distanceToOrigin () const |
Returns the distance to the origin The distance to the origin is equivalent to the first line parameter. | |
double | absoluteDistance (const Vector2D &point) const |
Returns the absolute value of distance(point) | |
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 line. | |
bool | isRight (const Vector2D &rhs) const |
Return if the point given is right of the line. | |
Vector2D | closest (const Vector2D &point) const |
Calculates the point of closest approach on the line to the point. | |
Vector2D | closestToOrigin () const |
Returns the point closest to the origin. | |
double | lengthOnCurve (const Vector2D &from, const Vector2D &to) const |
Calculates the length on the curve between two points. | |
bool | isInvalid () const |
Indicates if all circle parameters are zero. | |
Vector2D | tangential () const |
Gives the tangential vector in the direction of positive advance on the line. | |
const Vector2D & | normal () const |
Getter for the unit normal vector of the line. | |
const Vector2D & | gradient () const |
Getter for the gradient of the distance field. | |
Vector2D | support () const |
Getter for the support point of the line being the point closest to the origin. | |
EForwardBackward | alignedWithFirst () const |
Returns if the direction of positive advance has a common component aligned or anti aligned with the first coordinate. | |
EForwardBackward | alignedWithSecond () const |
Returns if the direction of positive advance has a common component aligned or anti aligned with the second coordinate. | |
Vector2D | intersection (const Line2D &line) const |
Calculates the intersection point of two line. Infinity for parallels. | |
Transformations of the line | |
void | moveBy (const Vector2D &by) |
Actively moves the line in the direction given in place by the vector given. | |
void | moveAlongFirst (const double first) |
Actively moves the line in the direction given in place along the first coordinate. | |
void | moveAlongSecond (const double second) |
Actively moves the line in the direction given in place along the second coordinate. | |
Line2D | movedAlongFirst (const double first) const |
Return a copy of the line actively moved long the first coordinate. | |
Line2D | movedAlongSecond (const double second) const |
Return a copy of the line actively moved long the first 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. | |
Line2D | passiveMovedAlongFirst (const double first) const |
Return a copy of the line passively moved long the first coordinate. | |
Line2D | passiveMovedAlongSecond (const double second) const |
Return a copy of the line passively moved long the first coordinate. | |
void | flipFirst () |
Flips the first coordinate inplace (no difference between active and passive) | |
void | flipSecond () |
Flips the first coordinate inplace (no difference between active and passive) | |
Line2D | flippedFirst () const |
Makes a copy of the line with the first coordinate flipped (no difference between active and passive) | |
Line2D | flippedSecond () const |
Makes a copy of the line with the second coordinate flipped (no difference between active and passive) | |
Line as a function of the first coordinate | |
double | slope () const |
Returns the slope over the first coordinate. | |
double | inverseSlope () const |
Returns the slope over the second coordinate. | |
double | intercept () const |
Returns the intercept over the first coordinate. | |
double | zero () const |
Returns the root of the line. | |
double | map (const double first) const |
Maps the first coordinate to the second. | |
double | operator() (const double first) const |
Maps the first coordinate to the second. | |
double | inverseMap (const double second) const |
Maps the second coordinate to the first. | |
void | invert () |
Turns the line function into its inverse function in place. | |
Line2D | inverted () const |
Returns the inverse function line as a copy. | |
Static Public Member Functions | |
static Line2D | fromSlopeIntercept (const double slope, const double intercept) |
Constructs a line from its slope and intercept over the first coordinate (default forward orientation). | |
static Line2D | fromSlopeIntercept (const double slope, const double intercept, const EForwardBackward orientation) |
Constructs a line from its slope and intercept over the first coordinate with the given orientation. | |
static Line2D | throughPoints (const Vector2D &start, const Vector2D &end) |
Constructs a line through the two given points. | |
Private Member Functions | |
void | setN1 (const double n1) |
Setter for the second line parameter. May violate the normalization. | |
void | setN2 (const double n2) |
Setter for the third line parameter. May violate the normalization. | |
void | setN12 (const double n1, const double n2) |
Setter for the normal vector by its coordinates. | |
void | setN12 (const Vector2D &n12) |
Setter for the normal vector. | |
void | scaleN (const double factor) |
Scales all parameters. Helper for normalize. | |
double | normalizationSquared () const |
Calculates the squared normalization. Helper for normalize. | |
double | normalization () const |
Calculates the normalization. Helper for normalize. | |
Private Attributes | |
double | m_n0 |
Memory for the first line parameter. | |
Vector2D | m_n12 |
Memory for the second line parameter. | |
A two dimensional normal line.
This class represents a line in two dimensional space by its normal definition n0 + n1*x + n2*y = 0 subjected to n1*n1 + n2*n2 = 1. The vector (n1, n2) is called unit normal vector. It has an orientation. It is defining a right half plane with all points having n0 + n1*x + n2*y > 0 and a left half plane for point having n0 + n1*x + n2*y < 0 This naturally corresponds to a direction of positive advance being the tangential to the line (-n2, n1). This line is best suited for linear least square fits.
|
inline |
Default constructor for ROOT compatibility.
Definition at line 41 of file Line2D.h.
|
inline |
Constructs taking all three line parameters.
Definition at line 48 of file Line2D.h.
Constructs taking the distance to the origin ( n0 ) and the normal vector.
Definition at line 56 of file Line2D.h.
|
inline |
Returns the absolute value of distance(point)
Definition at line 268 of file Line2D.h.
|
inline |
Returns if the direction of positive advance has a common component aligned or anti aligned with the first coordinate.
Definition at line 349 of file Line2D.h.
|
inline |
Returns if the direction of positive advance has a common component aligned or anti aligned with the second coordinate.
Calculates the point of closest approach on the line to the point.
|
inline |
|
inline |
Calculates the signed distance of the point given by its to coordinates to the line.
Returns the signed distance of the point to the line. The sign is positive
for the right side of the line and negative for the left side.
|
inline |
|
inline |
|
inline |
Flips the first coordinate inplace (no difference between active and passive)
Definition at line 427 of file Line2D.h.
|
inline |
Makes a copy of the line with the first coordinate flipped (no difference between active and passive)
Definition at line 440 of file Line2D.h.
|
inline |
Makes a copy of the line with the second coordinate flipped (no difference between active and passive)
Definition at line 447 of file Line2D.h.
|
inline |
Flips the first coordinate inplace (no difference between active and passive)
Definition at line 433 of file Line2D.h.
|
inlinestatic |
Constructs a line from its slope and intercept over the first coordinate (default forward orientation).
Constructs a line of the points fulfilling y = slope *x + intercept. The Line2D has an additional orientation in contrast to y = slope *x + intercept. The default orientation for the line is forward with the positive x axes.
Definition at line 70 of file Line2D.h.
|
inlinestatic |
Constructs a line from its slope and intercept over the first coordinate with the given orientation.
Constructs a line of the points fulfilling y = slope *x + intercept. The Line2D has an additional orientation in contrast to y = slope *x + intercept. The forward backward info sets if the constructed line shall have the direction with increasing or
decreasing x respectively.
|
inline |
|
inline |
Calculates the intersection point of two line. Infinity for parallels.
Definition at line 15 of file Line2D.cc.
|
inline |
Sets all line parameters to zero.
Definition at line 170 of file Line2D.h.
|
inline |
|
inline |
|
inline |
Turns the line function into its inverse function in place.
Definition at line 498 of file Line2D.h.
|
inline |
|
inline |
Indicates if all circle parameters are zero.
|
inline |
Return if the point given is left of the line.
Definition at line 280 of file Line2D.h.
|
inline |
Return if the point given is right of the line.
|
inline |
Return if the point given is right or left of the line.
Definition at line 274 of file Line2D.h.
Calculates the length on the curve between two points.
Takes to two point to their closest approach to the origin and calculates the distance between them. The length is signed taken relative to the direction of positive advance.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Getter for the second line parameter.
|
inline |
|
inline |
Getter for the third line parameter.
|
inline |
|
inlineprivate |
Calculates the normalization. Helper for normalize.
Definition at line 232 of file Line2D.h.
|
inlineprivate |
Calculates the squared normalization. Helper for normalize.
|
inline |
Updates the parameters to obey the normalization condition.
Definition at line 198 of file Line2D.h.
|
inline |
Maps the first coordinate to the second.
Definition at line 486 of file Line2D.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineprivate |
|
inline |
Setter the for the line parameters which takes care of the correct normalization of the normal vector.
Definition at line 162 of file Line2D.h.
|
inline |
|
inlineprivate |
Setter for the second line parameter. May violate the normalization.
Definition at line 136 of file Line2D.h.
|
inlineprivate |
Setter for the normal vector by its coordinates.
Definition at line 148 of file Line2D.h.
|
inlineprivate |
|
inlineprivate |
Setter for the third line parameter. May violate the normalization.
Definition at line 142 of file Line2D.h.
|
inline |
Sets the new intercept and slope of the line the direction is set to be forward with the increasing x axes.
Definition at line 177 of file Line2D.h.
|
inline |
Sets the new intercept and slope of the line the direction is set to be forward with the increasing x axes.
|
inline |
|
inline |
Getter for the support point of the line being the point closest to the origin.
Definition at line 342 of file Line2D.h.
|
inline |
Gives the tangential vector in the direction of positive advance on the line.
Definition at line 324 of file Line2D.h.
|
inline |
|
private |