Ocean
Ocean::LineT2< T > Class Template Reference

This class implements an infinite line in 2D space. More...

Inheritance diagram for Ocean::LineT2< T >:

Public Types

typedef T Type
 Definition of the used data type. More...
 

Public Member Functions

 LineT2 ()
 Creates an invalid line. More...
 
 LineT2 (const VectorT2< T > &point, const VectorT2< T > &direction)
 Creates a line defined by a point on the line and a line direction. More...
 
 LineT2 (const VectorT3< T > &parameters)
 Creates a new line object by given (implicit) three-parameter representation of the line. More...
 
 LineT2 (const T angle, const T distance)
 Creates a new line object by a given angle of the line's normal and the distance of the line to the origin. More...
 
template<typename U >
 LineT2 (const LineT2< U > &line)
 Copies a line with different data type than T. More...
 
const VectorT2< T > & point () const
 Returns a point on the line. More...
 
VectorT2< T > point (const T distance) const
 Returns a point on the line that is defined by a scalar. More...
 
const VectorT2< T > & direction () const
 Returns the direction of the line. More...
 
VectorT2< T > normal () const
 Returns a normal to the direction of this line. More...
 
void decomposeAngleDistance (T &angle, T &distance) const
 Calculates the angle of the line's normal and the corresponding distance of this line to the origin. More...
 
VectorT3< T > decomposeNormalDistance (const bool forcePositiveDistance=false) const
 Calculates the (implicit) three-parameters representation of this line composed of the line's normal and a distance parameter (nx, ny, d). More...
 
bool isOnLine (const VectorT2< T > &point) const
 Returns whether a given point is part of the 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...
 
distance (const VectorT2< T > &point) const
 Returns the distance between the line and a given point. More...
 
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 on this line nearest to an arbitrary given point. More...
 
bool intersection (const LineT2< T > &right, VectorT2< T > &point) const
 Returns the unique intersection point of two lines. More...
 
bool isParallel (const LineT2< T > &right) const
 Returns whether two lines are parallel up to a small epsilon. More...
 
bool isValid () const
 Returns whether this line has valid parameters. More...
 
bool hasUnitDirection () const
 Returns whether this line has a unit vector as direction. More...
 
bool operator== (const LineT2< T > &right) const
 Returns whether two line are identical up to a small epsilon. More...
 
bool operator!= (const LineT2< 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...
 
bool isOnLine (const VectorT2< float > &point) const
 

Static Public Member Functions

static bool fitLineLeastSquare (const VectorT2< T > *points, const size_t size, LineT2< T > &line)
 Fits a line to a set of given image points by application of the least square measure. More...
 

Protected Attributes

VectorT2< T > linePoint
 Point on the line. More...
 
VectorT2< T > lineDirection
 Direction of the line. More...
 

Friends

template<typename U >
class LineT2
 

Detailed Description

template<typename T>
class Ocean::LineT2< T >

This class implements an infinite line in 2D space.

The implementation is realized by an (explicit) parametric equation using a point on the line and the direction of the line.
However, the line support conversion function to receive also an implicit equation.

Template Parameters
TData type used to represent lines
See also
Line2, LineF2, LineD2, FiniteLine2, FiniteLine.

Member Typedef Documentation

◆ Type

template<typename T >
typedef T Ocean::LineT2< T >::Type

Definition of the used data type.

Constructor & Destructor Documentation

◆ LineT2() [1/5]

template<typename T >
Ocean::LineT2< T >::LineT2

Creates an invalid line.

◆ LineT2() [2/5]

template<typename T >
Ocean::LineT2< T >::LineT2 ( const VectorT2< T > &  point,
const VectorT2< T > &  direction 
)

Creates a line defined by a point on the line and a line direction.

Parameters
pointPoint on the line
directionVector representing the direction of the line, a unit vector might be appropriate

◆ LineT2() [3/5]

template<typename T >
Ocean::LineT2< T >::LineT2 ( const VectorT3< T > &  parameters)
explicit

Creates a new line object by given (implicit) three-parameter representation of the line.

The representation is given by the normal and the distance parameter of the line so that for a point (x, y) lying on the plane the following holds: [nx, ny, d] * [x, y, 1] == 0.
The normal must be defined as unit vector.

Parameters
parametersThe three parameters given as 3D vector

◆ LineT2() [4/5]

template<typename T >
Ocean::LineT2< T >::LineT2 ( const T  angle,
const T  distance 
)

Creates a new line object by a given angle of the line's normal and the distance of the line to the origin.

The distance values is equal to the distance parameter of a (implicit) three-parameter representation of a line where the other two parameters define the normal of the plane.

Parameters
angleThe angle of the line's normal, with normal = [cos(angle), sin(angle)], in radian
distanceThe signed distance of the line to the origin, with range (-infinity, infinity)
See also
decomposeAngleDistance().

◆ LineT2() [5/5]

template<typename T >
template<typename U >
Ocean::LineT2< T >::LineT2 ( const LineT2< U > &  line)
inlineexplicit

Copies a line with different data type than T.

Parameters
lineThe line to copy
Template Parameters
UThe data type of the second line

Member Function Documentation

◆ decomposeAngleDistance()

template<typename T >
void Ocean::LineT2< T >::decomposeAngleDistance ( T &  angle,
T &  distance 
) const
inline

Calculates the angle of the line's normal and the corresponding distance of this line to the origin.

The resulting distance parameter is equivalent to the distance parameter of a (implicit) three-parameter representation of this line where the other two parameters define the normal of the plane.

Parameters
angleResulting angle of the line's normal which is defined by atan(normal.y() / normal.x()); with normal = [cos(angle), sin(angle)], in radian
distanceResulting signed distance between line and origin, is positive if the normal points towards the origin and negative if the normal points away from the origin

◆ decomposeNormalDistance()

template<typename T >
VectorT3< T > Ocean::LineT2< T >::decomposeNormalDistance ( const bool  forcePositiveDistance = false) const
inline

Calculates the (implicit) three-parameters representation of this line composed of the line's normal and a distance parameter (nx, ny, d).

For a point (x, y) lying on the plane the following holds: [nx, ny, d] * [x, y, 1] == 0.

Parameters
forcePositiveDistanceTrue, to force a positive distance values; False, to accept positive and negative distance values
Returns
The resulting three parameter representation

◆ direction()

template<typename T >
const VectorT2< T > & Ocean::LineT2< T >::direction
inline

Returns the direction of the line.

Returns
Direction vector

◆ distance()

template<typename T >
T Ocean::LineT2< T >::distance ( const VectorT2< T > &  point) const

Returns the distance between the line and a given point.

This function needs a unit vector as direction!

Parameters
pointPoint to return the distance for
Returns
The always positive distance between point and line, with range [0, infinity)

◆ fitLineLeastSquare()

template<typename T >
bool Ocean::LineT2< T >::fitLineLeastSquare ( const VectorT2< T > *  points,
const size_t  size,
LineT2< T > &  line 
)
inlinestatic

Fits a line to a set of given image points by application of the least square measure.

Parameters
pointsThe points for which the best fitting line is requested, must be valid
sizeThe number of given points, with range [2, infinity)
lineThe resulting line
Returns
True, if succeeded

◆ hasUnitDirection()

template<typename T >
bool Ocean::LineT2< T >::hasUnitDirection
inline

Returns whether this line has a unit vector as direction.

Returns
True, if so

◆ intersection()

template<typename T >
bool Ocean::LineT2< T >::intersection ( const LineT2< T > &  right,
VectorT2< T > &  point 
) const

Returns the unique intersection point of two lines.

Two identical lines do not have one unique intersection point, so that this function will return 'false' in such a case. This function needs a unit vector as direction!

Parameters
rightRight line for intersection calculation
pointResulting intersection pointer
Returns
True, if both lines are not parallel

◆ isLeftOfLine()

template<typename T >
bool Ocean::LineT2< T >::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.

It's on the line the cross product is zero and in the right half-plane it is negative.

Note
Keep in mind that if the point is not in the left half-plane, it doesn't necessarily mean that it's in the right half-plane because it could just as well be located on the line.
Parameters
pointPoint to check
Returns
True, if the point is in the left half-plane

◆ isOnLine() [1/2]

bool Ocean::LineT2< float >::isOnLine ( const VectorT2< float > &  point) const
inline

◆ isOnLine() [2/2]

template<typename T >
bool Ocean::LineT2< T >::isOnLine ( const VectorT2< T > &  point) const

Returns whether a given point is part of the line.

This function needs a unit vector as direction!

Parameters
pointPoint to check
Returns
True, if so

◆ isParallel()

template<typename T >
bool Ocean::LineT2< T >::isParallel ( const LineT2< T > &  right) const

Returns whether two lines are parallel up to a small epsilon.

This function needs a unit vector as direction!

Parameters
rightSecond line
Returns
True, if so

◆ isValid()

template<typename T >
bool Ocean::LineT2< T >::isValid
inline

Returns whether this line has valid parameters.

Returns
True, if so

◆ nearestPoint()

template<typename T >
VectorT2< T > Ocean::LineT2< T >::nearestPoint ( const VectorT2< T > &  point) const

Returns the point on this line nearest to an arbitrary given point.

This function needs a unit vector as direction!

Parameters
pointArbitrary point outside the line
Returns
Nearest point on the line

◆ normal()

template<typename T >
VectorT2< T > Ocean::LineT2< T >::normal
inline

Returns a normal to the direction of this line.

The 2D cross product between the resulting normal and the direction of this line will be positive.

Returns
The resulting normal

◆ operator bool()

template<typename T >
Ocean::LineT2< T >::operator bool
inlineexplicit

Returns whether this line is valid.

Returns
True, if so

◆ operator!=()

template<typename T >
bool Ocean::LineT2< T >::operator!= ( const LineT2< T > &  right) const
inline

Returns whether two line are identical up to a small epsilon.

Parameters
rightRight line
Returns
True, if so

◆ operator==()

template<typename T >
bool Ocean::LineT2< T >::operator== ( const LineT2< T > &  right) const

Returns whether two line are identical up to a small epsilon.

Parameters
rightRight line
Returns
True, if so

◆ point() [1/2]

template<typename T >
const VectorT2< T > & Ocean::LineT2< T >::point
inline

Returns a point on the line.

Returns
Point on line

◆ point() [2/2]

template<typename T >
VectorT2< T > Ocean::LineT2< T >::point ( const T  distance) const
inline

Returns a point on the line that is defined by a scalar.

The result is determined by point() + direction() * distance;

Parameters
distanceDistance to determine the line point for
Returns
Point on line

◆ sqrDistance()

template<typename T >
T Ocean::LineT2< T >::sqrDistance ( const VectorT2< T > &  point) const

Returns the square distance between the line and a given point.

Parameters
pointPoint to return the distance for
Returns
Square distance between point and line

Friends And Related Function Documentation

◆ LineT2

template<typename T >
template<typename U >
friend class LineT2
friend

Field Documentation

◆ lineDirection

template<typename T >
VectorT2<T> Ocean::LineT2< T >::lineDirection
protected

Direction of the line.

◆ linePoint

template<typename T >
VectorT2<T> Ocean::LineT2< T >::linePoint
protected

Point on the line.


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