Ocean
|
This class implements an finite line in 2D space. More...
Public Types | |
typedef T | Type |
Definition of the used data type. More... | |
Public Member Functions | |
FiniteLineT2 ()=default | |
Creates a finite line with default parameters. More... | |
FiniteLineT2 (const VectorT2< T > &point0, const VectorT2< T > &point1) | |
Creates a finite line defined by two end points of the line. More... | |
template<typename U > | |
FiniteLineT2 (const FiniteLineT2< U > &line) | |
Copies a line with different data type than T. More... | |
const VectorT2< T > & | point0 () const |
Returns the first end point of the line. More... | |
const VectorT2< T > & | point1 () const |
Returns the second end point of the line. More... | |
const VectorT2< T > & | point (const unsigned int index) const |
Returns the first or second end point of the line. More... | |
VectorT2< T > | midpoint () const |
Returns the midpoint of the line. More... | |
const VectorT2< T > & | direction () const |
Returns the direction of the line: normalized(point1() - point0()) More... | |
const VectorT2< T > | normal () const |
Returns the normal of the line: -direction().perpendicular() The 2D cross product between the resulting normal and the direction of this line will be positive. More... | |
T | sqrLength () const |
Returns the squared length of the finite line. More... | |
T | length () const |
Returns the length of the finite line. More... | |
bool | isOnLine (const VectorT2< T > &point) const |
Returns whether a given point is part of the finite line. More... | |
bool | isOnInfiniteLine (const VectorT2< T > &point) const |
Returns whether a given point lies on the infinite line defined by this finite line. More... | |
bool | isLeftOfLine (const VectorT2< T > &point) const |
Check if a point is in the left half-plane of the direction vector of a line A point p is located on the left side of a line, if the cross product of the direction of the line, d , and the vector pointing from starting point of the line, s , to the point p is positive: (d x (p - s)) > 0. More... | |
T | distance (const VectorT2< T > &point) const |
Returns the distance between the line and a given point. More... | |
T | sqrDistance (const VectorT2< T > &point) const |
Returns the square distance between the line and a given point. More... | |
VectorT2< T > | nearestPoint (const VectorT2< T > &point) const |
Returns the point lying on this finite line nearest to an arbitrary given point. More... | |
VectorT2< T > | nearestPointOnInfiniteLine (const VectorT2< T > &point, T *outOfBoundaryDistance=nullptr, T *finiteLineLocation=nullptr) const |
Returns the point on the infinite line (defined by this finite line) to an arbitrary given point. More... | |
bool | intersection (const FiniteLineT2< T > &second, VectorT2< T > &point) const |
Returns the unique intersection point of two finite lines. More... | |
bool | intersection (const LineT2< T > &second, VectorT2< T > &point) const |
Returns the unique intersection point of this finite line with an infinite line. More... | |
bool | intersects (const FiniteLineT2< T > &second) const |
Returns whether two finite lines have a unique intersection point. More... | |
bool | intersects (const LineT2< T > &second) const |
Returns whether two finite lies have an intersection. More... | |
bool | isParallel (const FiniteLineT2< T > &right) const |
Returns whether two lines are parallel up to a small epsilon. More... | |
bool | isCollinear (const FiniteLineT2< T > &right, const T &distanceEpsilon=NumericT< T >::weakEps(), const T &cosAngleEpsilon=NumericT< T >::cos(NumericT< T >::weakEps())) const |
Check for collinearity with other line segment. More... | |
bool | isValid () const |
Returns whether this line has valid parameters. More... | |
bool | isEqual (const FiniteLineT2< T > &line, const T &epsilon) const |
Returns whether two lines are equal up to a specified epsilon. More... | |
bool | operator== (const FiniteLineT2< T > &right) const |
Returns whether two line are identical up to a small epsilon. More... | |
bool | operator!= (const FiniteLineT2< T > &right) const |
Returns whether two line are identical up to a small epsilon. More... | |
operator bool () const | |
Returns whether this line is valid. More... | |
Protected Attributes | |
VectorT2< T > | point0_ = VectorT2<T>(T(0), T(0)) |
First end point of the line. More... | |
VectorT2< T > | point1_ = VectorT2<T>(T(0), T(0)) |
Second end point of the line. More... | |
VectorT2< T > | direction_ = VectorT2<T>(T(0), T(0)) |
Direction of the line with unit length, if the object holds valid parameters. More... | |
This class implements an finite line in 2D space.
The finite line object is invalid if both end points of the line object are identical.
T | Data type used to represent lines |
typedef T Ocean::FiniteLineT2< T >::Type |
Definition of the used data type.
|
default |
Creates a finite line with default parameters.
Ocean::FiniteLineT2< T >::FiniteLineT2 | ( | const VectorT2< T > & | point0, |
const VectorT2< T > & | point1 | ||
) |
Creates a finite line defined by two end points of the line.
point0 | First end point of the line |
point1 | Second end point of the line, must be different from point0 to create a valid line, otherwise the line is invalid |
|
inlineexplicit |
Copies a line with different data type than T.
line | The line to copy |
U | The data type of the second line |
|
inline |
|
inline |
Returns the distance between the line and a given point.
This function needs a unit vector as direction!
point | The point to return the distance for |
|
inline |
Returns the unique intersection point of two finite lines.
Two aligned lines do not have one common intersection point, so that the function will return 'false' in such a case.
second | The second line for intersection calculation |
point | Resulting intersection point |
|
inline |
Returns the unique intersection point of this finite line with an infinite line.
Two aligned lines do not have one common intersection point, so that the function will return 'false' in such a case.
second | The second line for intersection calculation |
point | Resulting intersection point |
|
inline |
Returns whether two finite lines have a unique intersection point.
second | The second line to check |
|
inline |
Returns whether two finite lies have an intersection.
second | The second line to check |
|
inline |
Check for collinearity with other line segment.
right | Line to check for collinearity |
distanceEpsilon | Acceptable distance of the endpoints of one line segment from the infinite line corresponding to the other line, default value: Numeric::weakEps() |
cosAngleEpsilon | Cosine of the maximum angle that is allowed in order for the two segments to be considered parallel; default: cos(weakEps()), i.e., approx. one, range: [0, 1] |
|
inline |
Returns whether two lines are equal up to a specified epsilon.
Two lines are equal if both lines have the same end points (while the order of the points is not important).
line | The second line to be used for comparison, must be valid |
epsilon | The maximal distance between two equal end points, with range [0, infinity) |
|
inline |
Check if a point is in the left half-plane of the direction vector of a line A point p
is located on the left side of a line, if the cross product of the direction of the line, d
, and the vector pointing from starting point of the line, s
, to the point p
is positive: (d x (p - s)) > 0.
It's on the line the cross product is zero and in the right half-plane it is negative.
point | The point to check |
|
inline |
Returns whether a given point lies on the infinite line defined by this finite line.
point | The point to check |
|
inline |
Returns whether a given point is part of the finite line.
point | The point to check |
|
inline |
Returns whether two lines are parallel up to a small epsilon.
right | Second line |
|
inline |
Returns whether this line has valid parameters.
|
inline |
Returns the length of the finite line.
|
inline |
Returns the midpoint of the line.
VectorT2< T > Ocean::FiniteLineT2< T >::nearestPoint | ( | const VectorT2< T > & | point | ) | const |
Returns the point lying on this finite line nearest to an arbitrary given point.
This function needs a unit vector as direction!
point | Arbitrary point outside the line |
VectorT2< T > Ocean::FiniteLineT2< T >::nearestPointOnInfiniteLine | ( | const VectorT2< T > & | point, |
T * | outOfBoundaryDistance = nullptr , |
||
T * | finiteLineLocation = nullptr |
||
) | const |
Returns the point on the infinite line (defined by this finite line) to an arbitrary given point.
In addition to providing the projected point on the infinite line, this function can return the distance to the closest end point of the finite line when lying outside of the finite line's boundaries. A negative distance indicates a projected point close to point0(), a positive distance indicates a projected point close to point1(). This function needs a unit vector as direction!
point | Arbitrary point outside the line |
outOfBoundaryDistance | Optional resulting distance between the projected point on the infinite line and the closest end point of the finite line, with range (-infinity, infinity) |
finiteLineLocation | Optional resulting location of the projected point in relation to the finite line so that the following holds point() + direction() * finiteLineLocation, with range (-infinity, infinity) |
|
inline |
Returns the normal of the line: -direction().perpendicular() The 2D cross product between the resulting normal and the direction of this line will be positive.
|
inlineexplicit |
Returns whether this line is valid.
|
inline |
Returns whether two line are identical up to a small epsilon.
right | The right line |
|
inline |
Returns whether two line are identical up to a small epsilon.
Two finite lines are identical if both lines have the same endpoint (independent of the order of the end points).
right | The right line |
|
inline |
Returns the first or second end point of the line.
index | The index of the point to be returned, with range [0, 1] |
|
inline |
Returns the first end point of the line.
|
inline |
Returns the second end point of the line.
|
inline |
Returns the square distance between the line and a given point.
point | The point to return the distance for |
|
inline |
Returns the squared length of the finite line.
|
protected |
Direction of the line with unit length, if the object holds valid parameters.
|
protected |
First end point of the line.
|
protected |
Second end point of the line.