Belle II Software development
Line2D Class Reference

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 Vector2Dn12 () 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 positiv advance on the line.
 
const Vector2Dnormal () const
 Getter for the unit normal vector of the line.
 
const Vector2Dgradient () 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 positiv advance has a common component aligned or anti aligned with the first coordinate.
 
EForwardBackward alignedWithSecond () const
 Returns if the direction of positiv 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)
 Activelly moves the line in the direction given in place by the vector given.
 
void moveAlongFirst (const double first)
 Activelly moves the line in the direction given in place along the first coordinate.
 
void moveAlongSecond (const double second)
 Activelly 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 activally moved long the first coordinate.
 
Line2D movedAlongSecond (const double second) const
 Return a copy of the line activally moved long the first coordinate.
 
void passiveMoveBy (const Vector2D &by)
 Passivelly 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 pasive)
 
void flipSecond ()
 Flips the first coordinate inplace (no difference between active and pasive)
 
Line2D flippedFirst () const
 Makes a copy of the line with the first coordinate flipped (no difference between active and pasive)
 
Line2D flippedSecond () const
 Makes a copy of the line with the second coordinate flipped (no difference between active and pasive)
 
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 normlization.
 
void setN2 (const double n2)
 Setter for the third line parameter. May violate the normlization.
 
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.
 

Detailed Description

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 positiv advance being the tangential to the line (-n2, n1). This line is best suited for linear least square fits.

Definition at line 37 of file Line2D.h.

Constructor & Destructor Documentation

◆ Line2D() [1/3]

Line2D ( )
inline

Default constructor for ROOT compatibility.

Definition at line 41 of file Line2D.h.

42 : m_n0(0.0)
43 , m_n12(0.0, 0.0)
44 {
45 }
double m_n0
Memory for the first line parameter.
Definition: Line2D.h:513
Vector2D m_n12
Memory for the second line parameter.
Definition: Line2D.h:516

◆ Line2D() [2/3]

Line2D ( const double  n0,
const double  n1,
const double  n2 
)
inline

Constructs taking all three line parameters.

Definition at line 48 of file Line2D.h.

49 : m_n0(n0)
50 , m_n12(n1, n2)
51 {
52 normalize();
53 }
double n1() const
Getter for the second line parameter.
Definition: Line2D.h:105
double n2() const
Getter for the third line parameter.
Definition: Line2D.h:111
void normalize()
Updates the parameters to obey the normalization condition.
Definition: Line2D.h:198
double n0() const
Getter for the first line parameter.
Definition: Line2D.h:99

◆ Line2D() [3/3]

Line2D ( const double  n0,
const Vector2D n12 
)
inline

Constructs taking the distance to the origin ( n0 ) and the normal vector.

Definition at line 56 of file Line2D.h.

57 : m_n0(n0)
58 , m_n12(n12)
59 {
60 normalize();
61 }
const Vector2D & n12() const
Getter for the unit normal vector to the line.
Definition: Line2D.h:117

Member Function Documentation

◆ absoluteDistance()

double absoluteDistance ( const Vector2D point) const
inline

Returns the absolute value of distance(point)

Definition at line 268 of file Line2D.h.

269 {
270 return fabs(distance(point));
271 }
double distance(const Vector2D &point) const
Calculates the signed distance of the point to the line.
Definition: Line2D.h:243

◆ alignedWithFirst()

EForwardBackward alignedWithFirst ( ) const
inline

Returns if the direction of positiv advance has a common component aligned or anti aligned with the first coordinate.

Definition at line 349 of file Line2D.h.

350 {
351 return static_cast<EForwardBackward>(-sign(n2()));
352 }
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.

◆ alignedWithSecond()

EForwardBackward alignedWithSecond ( ) const
inline

Returns if the direction of positiv advance has a common component aligned or anti aligned with the second coordinate.

Definition at line 356 of file Line2D.h.

357 {
358 return static_cast<EForwardBackward>(sign(n1()));
359 }

◆ closest()

Vector2D closest ( const Vector2D point) const
inline

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

Definition at line 292 of file Line2D.h.

293 {
294 const double closestParallel = -n0();
295 const double closestOrthgonal = point.unnormalizedOrthogonalComp(n12());
296 return Vector2D(n12(), closestParallel, closestOrthgonal);
297 }

◆ closestToOrigin()

Vector2D closestToOrigin ( ) const
inline

Returns the point closest to the origin.

Definition at line 300 of file Line2D.h.

301 {
302 return n12() * (-n0());
303 }

◆ distance() [1/2]

double distance ( const double  first,
const double  second 
) const
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 positiv
for the right side of the line and negativ for the left side.

Definition at line 253 of file Line2D.h.

254 {
255 return n0() + first * n1() + second * n2();
256 }

◆ distance() [2/2]

double distance ( const Vector2D point) const
inline

Calculates the signed distance of the point to the line.

Returns the signed distance of the point to the line. The sign is positiv
for the right side of the line and negativ for the left side.

Definition at line 243 of file Line2D.h.

244 {
245 return n0() + point.dot(n12());
246 }

◆ distanceToOrigin()

double distanceToOrigin ( ) const
inline

Returns the distance to the origin The distance to the origin is equivalent to the first line parameter.

Definition at line 262 of file Line2D.h.

263 {
264 return n0();
265 }

◆ flipFirst()

void flipFirst ( )
inline

Flips the first coordinate inplace (no difference between active and pasive)

Definition at line 427 of file Line2D.h.

428 {
430 }
void flipFirst()
Flips the first coordinate inplace (no difference between active and passive)
Definition: Vector2D.h:345

◆ flippedFirst()

Line2D flippedFirst ( ) const
inline

Makes a copy of the line with the first coordinate flipped (no difference between active and pasive)

Definition at line 440 of file Line2D.h.

441 {
442 return Line2D(n0(), n12().flippedFirst());
443 }
Line2D()
Default constructor for ROOT compatibility.
Definition: Line2D.h:41
Line2D flippedFirst() const
Makes a copy of the line with the first coordinate flipped (no difference between active and pasive)
Definition: Line2D.h:440

◆ flippedSecond()

Line2D flippedSecond ( ) const
inline

Makes a copy of the line with the second coordinate flipped (no difference between active and pasive)

Definition at line 447 of file Line2D.h.

448 {
449 return Line2D(n0(), n12().flippedSecond());
450 }
Line2D flippedSecond() const
Makes a copy of the line with the second coordinate flipped (no difference between active and pasive)
Definition: Line2D.h:447

◆ flipSecond()

void flipSecond ( )
inline

Flips the first coordinate inplace (no difference between active and pasive)

Definition at line 433 of file Line2D.h.

434 {
436 }
void flipSecond()
Flips the first coordinate inplace (no difference between active and passive)
Definition: Vector2D.h:351

◆ fromSlopeIntercept() [1/2]

static Line2D fromSlopeIntercept ( const double  slope,
const double  intercept 
)
inlinestatic

Constructs a line from its slope and intercept over the first coordinate (default forward orientation).

Constucts a line of the points fullfilling 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 positiv x axes.

Definition at line 70 of file Line2D.h.

71 {
72 return Line2D(intercept, slope, -EForwardBackward::c_Forward);
73 }
double slope() const
Returns the slope over the first coordinate.
Definition: Line2D.h:457
double intercept() const
Returns the intercept over the first coordinate.
Definition: Line2D.h:469

◆ fromSlopeIntercept() [2/2]

static Line2D fromSlopeIntercept ( const double  slope,
const double  intercept,
const EForwardBackward  orientation 
)
inlinestatic

Constructs a line from its slope and intercept over the first coordinate with the given orientation.

Constucts a line of the points fullfilling 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 respectivly.

Definition at line 84 of file Line2D.h.

87 {
88 return Line2D(intercept * static_cast<double>(orientation), slope * static_cast<double>(orientation), -orientation);
89 }

◆ gradient()

const Vector2D & gradient ( ) const
inline

Getter for the gradient of the distance field.

Definition at line 336 of file Line2D.h.

337 {
338 return n12();
339 }

◆ intercept()

double intercept ( ) const
inline

Returns the intercept over the first coordinate.

Definition at line 469 of file Line2D.h.

470 {
471 return -n0() / n2();
472 }

◆ intersection()

Vector2D intersection ( const Line2D line) const

Calculates the intersection point of two line. Infinity for parallels.

Definition at line 15 of file Line2D.cc.

16{
17
18 double determinant = n12().cross(line.n12());
19 Vector2D result(-n0() * line.n2() + line.n0() * n2(), n0() * line.n1() - line.n0() * n1());
20
21 result /= determinant;
22 return result;
23}
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:32
double cross(const Vector2D &rhs) const
Calculated the two dimensional cross product.
Definition: Vector2D.h:163

◆ invalidate()

void invalidate ( )
inline

Sets all line parameters to zero.

Definition at line 170 of file Line2D.h.

171 {
172 setN(0.0, 0.0, 0.0);
173 }
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...
Definition: Line2D.h:162

◆ inverseMap()

double inverseMap ( const double  second) const
inline

Maps the second coordinate to the first.

Definition at line 492 of file Line2D.h.

493 {
494 return -(n0() + n2() * second) / n1();
495 }

◆ inverseSlope()

double inverseSlope ( ) const
inline

Returns the slope over the second coordinate.

Definition at line 463 of file Line2D.h.

464 {
465 return -n2() / n1();
466 }

◆ invert()

void invert ( )
inline

Turns the line function into its inverse function in place.

Definition at line 498 of file Line2D.h.

499 {
501 reverse();
502 }
void reverse()
Flips orientation the line in place.
Definition: Line2D.h:206
void swapCoordinates()
Swaps the coordinates in place.
Definition: Vector2D.h:551

◆ inverted()

Line2D inverted ( ) const
inline

Returns the inverse function line as a copy.

Definition at line 505 of file Line2D.h.

506 {
507 return Line2D(-n0(), -n2(), -n1());
508 }

◆ isInvalid()

bool isInvalid ( ) const
inline

Indicates if all circle parameters are zero.

Definition at line 318 of file Line2D.h.

319 {
320 return n0() == 0.0 and n12().isNull();
321 }
bool isNull() const
Checks if the vector is the null vector.
Definition: Vector2D.h:143

◆ isLeft()

bool isLeft ( const Vector2D rhs) const
inline

Return if the point given is left of the line.

Definition at line 280 of file Line2D.h.

281 {
282 return isRightOrLeft(rhs) == ERightLeft::c_Left;
283 }
ERightLeft isRightOrLeft(const Vector2D &point) const
Return if the point given is right or left of the line.
Definition: Line2D.h:274

◆ isRight()

bool isRight ( const Vector2D rhs) const
inline

Return if the point given is right of the line.

Definition at line 286 of file Line2D.h.

287 {
288 return isRightOrLeft(rhs) == ERightLeft::c_Right;
289 }

◆ isRightOrLeft()

ERightLeft isRightOrLeft ( const Vector2D point) const
inline

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

Definition at line 274 of file Line2D.h.

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

◆ lengthOnCurve()

double lengthOnCurve ( const Vector2D from,
const Vector2D to 
) const
inline

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 take relativ to the direction of positiv advance.

Definition at line 312 of file Line2D.h.

313 {
314 return to.unnormalizedOrthogonalComp(n12()) - from.unnormalizedOrthogonalComp(n12());
315 }

◆ map()

double map ( const double  first) const
inline

Maps the first coordinate to the second.

Definition at line 481 of file Line2D.h.

482 {
483 return -(n0() + n1() * first) / n2();
484 }

◆ moveAlongFirst()

void moveAlongFirst ( const double  first)
inline

Activelly moves the line in the direction given in place along the first coordinate.

Definition at line 373 of file Line2D.h.

374 {
375 m_n0 -= n1() * first;
376 }

◆ moveAlongSecond()

void moveAlongSecond ( const double  second)
inline

Activelly moves the line in the direction given in place along the second coordinate.

Definition at line 379 of file Line2D.h.

380 {
381 m_n0 -= n2() * second;
382 }

◆ moveBy()

void moveBy ( const Vector2D by)
inline

Activelly moves the line in the direction given in place by the vector given.

Definition at line 367 of file Line2D.h.

368 {
369 m_n0 -= by.unnormalizedParallelComp(n12());
370 }

◆ movedAlongFirst()

Line2D movedAlongFirst ( const double  first) const
inline

Return a copy of the line activally moved long the first coordinate.

Definition at line 385 of file Line2D.h.

386 {
387 return Line2D(n0() - n1() * first, n1(), n2());
388 }

◆ movedAlongSecond()

Line2D movedAlongSecond ( const double  second) const
inline

Return a copy of the line activally moved long the first coordinate.

Definition at line 391 of file Line2D.h.

392 {
393 return Line2D(n0() - n2() * second, n1(), n2());
394 }

◆ n0()

double n0 ( ) const
inline

Getter for the first line parameter.

Definition at line 99 of file Line2D.h.

100 {
101 return m_n0;
102 }

◆ n1()

double n1 ( ) const
inline

Getter for the second line parameter.

Definition at line 105 of file Line2D.h.

106 {
107 return m_n12.first();
108 }
double first() const
Getter for the first coordinate.
Definition: Vector2D.h:629

◆ n12()

const Vector2D & n12 ( ) const
inline

Getter for the unit normal vector to the line.

Definition at line 117 of file Line2D.h.

118 {
119 return m_n12;
120 }

◆ n2()

double n2 ( ) const
inline

Getter for the third line parameter.

Definition at line 111 of file Line2D.h.

112 {
113 return m_n12.second();
114 }
double second() const
Getter for the second coordinate.
Definition: Vector2D.h:639

◆ normal()

const Vector2D & normal ( ) const
inline

Getter for the unit normal vector of the line.

Definition at line 330 of file Line2D.h.

331 {
332 return n12();
333 }

◆ normalization()

double normalization ( ) const
inlineprivate

Calculates the normalization. Helper for normalize.

Definition at line 232 of file Line2D.h.

233 {
234 return sqrt(normalizationSquared());
235 }
double normalizationSquared() const
Calculates the squared normalization. Helper for normalize.
Definition: Line2D.h:226
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28

◆ normalizationSquared()

double normalizationSquared ( ) const
inlineprivate

Calculates the squared normalization. Helper for normalize.

Definition at line 226 of file Line2D.h.

227 {
228 return n12().normSquared();
229 }
double normSquared() const
Calculates .
Definition: Vector2D.h:169

◆ normalize()

void normalize ( )
inline

Updates the parameters to obey the normalization condition.

Definition at line 198 of file Line2D.h.

199 {
200 if (not isInvalid()) {
201 scaleN(1.0 / normalization());
202 }
203 }
double normalization() const
Calculates the normalization. Helper for normalize.
Definition: Line2D.h:232
bool isInvalid() const
Indicates if all circle parameters are zero.
Definition: Line2D.h:318
void scaleN(const double factor)
Scales all parameters. Helper for normalize.
Definition: Line2D.h:219

◆ operator()()

double operator() ( const double  first) const
inline

Maps the first coordinate to the second.

Definition at line 486 of file Line2D.h.

487 {
488 return map(first);
489 }
double map(const double first) const
Maps the first coordinate to the second.
Definition: Line2D.h:481

◆ passiveMoveAlongFirst()

void passiveMoveAlongFirst ( const double  first)
inline

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

Definition at line 403 of file Line2D.h.

404 {
405 m_n0 += n1() * first;
406 }

◆ passiveMoveAlongSecond()

void passiveMoveAlongSecond ( const double  second)
inline

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

Definition at line 409 of file Line2D.h.

410 {
411 m_n0 += n2() * second;
412 }

◆ passiveMoveBy()

void passiveMoveBy ( const Vector2D by)
inline

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

Definition at line 397 of file Line2D.h.

398 {
399 m_n0 += by.unnormalizedParallelComp(n12());
400 }

◆ passiveMovedAlongFirst()

Line2D passiveMovedAlongFirst ( const double  first) const
inline

Return a copy of the line passively moved long the first coordinate.

Definition at line 415 of file Line2D.h.

416 {
417 return Line2D(n0() + n1() * first, n1(), n2());
418 }

◆ passiveMovedAlongSecond()

Line2D passiveMovedAlongSecond ( const double  second) const
inline

Return a copy of the line passively moved long the first coordinate.

Definition at line 421 of file Line2D.h.

422 {
423 return Line2D(n0() + n2() * second, n1(), n2());
424 }

◆ reverse()

void reverse ( )
inline

Flips orientation the line in place.

Definition at line 206 of file Line2D.h.

207 {
208 scaleN(-1.0);
209 }

◆ reversed()

Line2D reversed ( ) const
inline

Returns a copy of the line with the reversed orientation.

Definition at line 212 of file Line2D.h.

213 {
214 return Line2D(-n0(), -n1(), -n2());
215 }

◆ scaleN()

void scaleN ( const double  factor)
inlineprivate

Scales all parameters. Helper for normalize.

Definition at line 219 of file Line2D.h.

220 {
221 m_n0 *= factor;
222 m_n12 *= factor;
223 }

◆ setN()

void setN ( const double  n0,
const double  n1,
const double  n2 
)
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.

163 {
164 setN0(n0);
165 setN12(n1, n2);
166 normalize();
167 }
void setN0(const double n0)
Setter for first line parameter This sets the signed distance of the line to the origin.
Definition: Line2D.h:129
void setN12(const double n1, const double n2)
Setter for the normal vector by its coordinates.
Definition: Line2D.h:148

◆ setN0()

void setN0 ( const double  n0)
inline

Setter for first line parameter This sets the signed distance of the line to the origin.

Its not involved in the normalization hence it can be exported as a public function.

Definition at line 129 of file Line2D.h.

130 {
131 m_n0 = n0;
132 }

◆ setN1()

void setN1 ( const double  n1)
inlineprivate

Setter for the second line parameter. May violate the normlization.

Definition at line 136 of file Line2D.h.

137 {
139 }
void setFirst(const double first)
Setter for the first coordinate.
Definition: Vector2D.h:634

◆ setN12() [1/2]

void setN12 ( const double  n1,
const double  n2 
)
inlineprivate

Setter for the normal vector by its coordinates.

Definition at line 148 of file Line2D.h.

149 {
150 m_n12.set(n1, n2);
151 }
void set(const double first, const double second)
Setter for both coordinate.
Definition: Vector2D.h:650

◆ setN12() [2/2]

void setN12 ( const Vector2D n12)
inlineprivate

Setter for the normal vector.

Definition at line 154 of file Line2D.h.

155 {
156 m_n12.set(n12);
157 }

◆ setN2()

void setN2 ( const double  n2)
inlineprivate

Setter for the third line parameter. May violate the normlization.

Definition at line 142 of file Line2D.h.

143 {
145 }
void setSecond(const double second)
Setter for the second coordinate.
Definition: Vector2D.h:644

◆ setSlopeIntercept() [1/2]

void setSlopeIntercept ( const double  slope,
const double  intercept 
)
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.

178 {
180 setN1(slope);
181 setN2(-1.0);
182 normalize();
183 }
void setN2(const double n2)
Setter for the third line parameter. May violate the normlization.
Definition: Line2D.h:142
void setN1(const double n1)
Setter for the second line parameter. May violate the normlization.
Definition: Line2D.h:136

◆ setSlopeIntercept() [2/2]

void setSlopeIntercept ( const double  slope,
const double  intercept,
const EForwardBackward  orientation 
)
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 187 of file Line2D.h.

190 {
191 setN0(intercept * static_cast<double>(orientation));
192 setN1(slope * static_cast<double>(orientation));
193 setN2(-orientation);
194 normalize();
195 }

◆ slope()

double slope ( ) const
inline

Returns the slope over the first coordinate.

Definition at line 457 of file Line2D.h.

458 {
459 return -n1() / n2();
460 }

◆ support()

Vector2D support ( ) const
inline

Getter for the support point of the line being the point closest to the origin.

Definition at line 342 of file Line2D.h.

343 {
344 return closestToOrigin();
345 }
Vector2D closestToOrigin() const
Returns the point closest to the origin.
Definition: Line2D.h:300

◆ tangential()

Vector2D tangential ( ) const
inline

Gives the tangential vector in the direction of positiv advance on the line.

Definition at line 324 of file Line2D.h.

325 {
326 return normal().orthogonal();
327 }
const Vector2D & normal() const
Getter for the unit normal vector of the line.
Definition: Line2D.h:330
Vector2D orthogonal() const
Orthogonal vector to the counterclockwise direction.
Definition: Vector2D.h:289

◆ throughPoints()

static Line2D throughPoints ( const Vector2D start,
const Vector2D end 
)
inlinestatic

Constructs a line through the two given points.

Definition at line 92 of file Line2D.h.

93 {
94 return Line2D(end.cross(start), (start - end).orthogonal());
95 }

◆ zero()

double zero ( ) const
inline

Returns the root of the line.

Definition at line 475 of file Line2D.h.

476 {
477 return -n0() / n1();
478 }

Member Data Documentation

◆ m_n0

double m_n0
private

Memory for the first line parameter.

Definition at line 513 of file Line2D.h.

◆ m_n12

Vector2D m_n12
private

Memory for the second line parameter.

Definition at line 516 of file Line2D.h.


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