Ocean
Ocean::CV::Bresenham Class Reference

This class implements bresenham line algorithms. More...

Public Types

enum  Orientation : uint32_t {
  ORIENTATION_INVALID = 0u , ORIENTATION_0 , ORIENTATION_1 , ORIENTATION_2 ,
  ORIENTATION_3 , ORIENTATION_4 , ORIENTATION_5 , ORIENTATION_6 ,
  ORIENTATION_7
}
 Definition of different line orientations. More...
 

Public Member Functions

 Bresenham ()
 Creates an invalid object. More...
 
 Bresenham (const int x0, const int y0, const int x1, const int y1)
 Creates a new Bresenham line. More...
 
void findNext (int &x, int &y)
 Applies one Bresenham step to find the next pixel. More...
 
bool isValid () const
 Returns whether this object holds a valid line. More...
 
Orientation orientation () const
 Returns the current orientation of the bresenham line. More...
 

Static Public Member Functions

static bool borderIntersection (const Line2 &line, const int leftBorder, const int topBorder, const int rightBorder, const int bottomBorder, int &x0, int &y0, int &x1, int &y1)
 Computes the pixel-precise border intersection (the begin and end position) of a sub-pixel-precise 2D line which needs be is visible within a specified pixel-precise frame only. More...
 
static bool borderIntersection (const Line2 &line, const Scalar leftBorder, const Scalar topBorder, const Scalar rightBorder, const Scalar bottomBorder, Scalar &x0, Scalar &y0, Scalar &x1, Scalar &y1)
 Computes the sub-pixel-precise border intersection (the begin and end position) of a sub-pixel-precise 2D line which needs be is visible within a specified pixel-precise frame only. More...
 
static unsigned int numberLinePixels (const int x0, const int y0, const int x1, const int y1)
 Determines the number of pixels necessary for a line between two given points. More...
 
static void intermediatePixels (const PixelPosition &position0, const PixelPosition &position1, PixelPositions &pixels)
 Determines the intermediate pixels between two given pixels. More...
 

Protected Attributes

Orientation orientation_
 Orientation parameter. More...
 
int control_
 Control parameter. More...
 
int updateX_
 Horizontal update value. More...
 
int updateXY_
 Horizontal and vertical update value. More...
 

Detailed Description

This class implements bresenham line algorithms.

Member Enumeration Documentation

◆ Orientation

Definition of different line orientations.

Enumerator
ORIENTATION_INVALID 

Invalid orientation.

ORIENTATION_0 

Line orientation with range [0, 45] degree.

ORIENTATION_1 

Line orientation with range (45, 90] degree.

ORIENTATION_2 

Line orientation with range [90, 135) degree.

ORIENTATION_3 

Line orientation with range [135, 180] degree.

ORIENTATION_4 

Line orientation with range [180, 225] degree.

ORIENTATION_5 

Line orientation with range (225, 270] degree.

ORIENTATION_6 

Line orientation with range (270, 315] degree.

ORIENTATION_7 

Line orientation with range (315, 360] degree.

Constructor & Destructor Documentation

◆ Bresenham() [1/2]

Ocean::CV::Bresenham::Bresenham ( )
inline

Creates an invalid object.

◆ Bresenham() [2/2]

Ocean::CV::Bresenham::Bresenham ( const int  x0,
const int  y0,
const int  x1,
const int  y1 
)

Creates a new Bresenham line.

Parameters
x0Horizontal start position of the line, with range (-infinity, infinity)
y0Vertical start position of the line, with range (-infinity, infinity)
x1Horizontal stop position of the line (inclusive), with range (-infinity, infinity)
y1Vertical stop position of the line (inclusive), with range (-infinity, infinity)

Member Function Documentation

◆ borderIntersection() [1/2]

static bool Ocean::CV::Bresenham::borderIntersection ( const Line2 line,
const int  leftBorder,
const int  topBorder,
const int  rightBorder,
const int  bottomBorder,
int &  x0,
int &  y0,
int &  x1,
int &  y1 
)
static

Computes the pixel-precise border intersection (the begin and end position) of a sub-pixel-precise 2D line which needs be is visible within a specified pixel-precise frame only.

The begin position will be at the left border, otherwise at the top border or bottom border (in this order).

Parameters
lineThe 2D line for which the begin position and end position will be determined, must be valid
leftBorderLeft inclusive pixel border (e.g. could be 0), with range (-infinity, infinity)
topBorderTop inclusive pixel border (e.g. could be 0), with range (-infinity, infinity)
rightBorderRight inclusive pixel border (e.g. could be width - 1), with range [leftBorder, infinity)
bottomBorderBottom inclusive pixel border (e.g. could be height - 1), with range [topBorder, infinity)
x0Resulting horizontal begin position in pixel, with range [leftBorder, rightBorder]
y0Resulting vertical begin position in pixel, with range [topBorder, bottomBorder]
x1Resulting horizontal end position in pixel, with range [leftBorder, rightBorder]
y1Resulting vertical end position in pixel, with range [topBorder, bottomBorder]
Returns
True, if the given line lies inside the defined frame

◆ borderIntersection() [2/2]

static bool Ocean::CV::Bresenham::borderIntersection ( const Line2 line,
const Scalar  leftBorder,
const Scalar  topBorder,
const Scalar  rightBorder,
const Scalar  bottomBorder,
Scalar x0,
Scalar y0,
Scalar x1,
Scalar y1 
)
static

Computes the sub-pixel-precise border intersection (the begin and end position) of a sub-pixel-precise 2D line which needs be is visible within a specified pixel-precise frame only.

The begin position will be at the left border, otherwise at the top border or bottom border (in this order).

Parameters
lineThe 2D line for which the begin position and end position will be determined, must be valid
leftBorderLeft inclusive pixel border (e.g. could be 0), with range (-infinity, infinity)
topBorderTop inclusive pixel border (e.g. could be 0), with range (-infinity, infinity)
rightBorderRight inclusive pixel border (e.g. could be width - 1), with range [leftBorder, infinity)
bottomBorderBottom inclusive pixel border (e.g. could be height - 1), with range [topBorder, infinity)
x0Resulting horizontal begin position in pixel, with range [leftBorder, rightBorder]
y0Resulting vertical begin position in pixel, with range [topBorder, bottomBorder]
x1Resulting horizontal end position in pixel, with range [leftBorder, rightBorder]
y1Resulting vertical end position in pixel, with range [topBorder, bottomBorder]
Returns
True, if the given line lies inside the defined frame

◆ findNext()

void Ocean::CV::Bresenham::findNext ( int &  x,
int &  y 
)

Applies one Bresenham step to find the next pixel.

Parameters
xCurrent horizontal position which will be updated, with range (-infinity, infinity)
yCurrent vertical position which will be updated, with range (-infinity, infinity)

◆ intermediatePixels()

static void Ocean::CV::Bresenham::intermediatePixels ( const PixelPosition position0,
const PixelPosition position1,
PixelPositions pixels 
)
static

Determines the intermediate pixels between two given pixels.

Parameters
position0Begin position of the line (excluding), with range (-infinity, infinity)x(-infinity, infinity)
position1End position of the line (excluding), with range (-infinity, infinity)x(-infinity, infinity)
pixelsThe resulting intermediate pixels

◆ isValid()

bool Ocean::CV::Bresenham::isValid ( ) const
inline

Returns whether this object holds a valid line.

Returns
True, if so

◆ numberLinePixels()

static unsigned int Ocean::CV::Bresenham::numberLinePixels ( const int  x0,
const int  y0,
const int  x1,
const int  y1 
)
static

Determines the number of pixels necessary for a line between two given points.

The number of pixels include the begin and end points.

Parameters
x0Horizontal begin position of the line, with range (-infinity, infinity)
y0Vertical begin position of the line, with range (-infinity, infinity)
x1Horizontal end position of the line, with range (-infinity, infinity)
y1Vertical end position of the line, with range (-infinity, infinity)
Returns
Number of line pixels, with range [1, infinity)

◆ orientation()

Bresenham::Orientation Ocean::CV::Bresenham::orientation ( ) const
inline

Returns the current orientation of the bresenham line.

Returns
The current orientation

Field Documentation

◆ control_

int Ocean::CV::Bresenham::control_
protected

Control parameter.

◆ orientation_

Orientation Ocean::CV::Bresenham::orientation_
protected

Orientation parameter.

◆ updateX_

int Ocean::CV::Bresenham::updateX_
protected

Horizontal update value.

◆ updateXY_

int Ocean::CV::Bresenham::updateXY_
protected

Horizontal and vertical update value.


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