SMIL 1.1.2
Loading...
Searching...
No Matches
Bresenham Class Reference

Bresenham Class. More...

Detailed Description

Bresenham Class.

Find intermediate points forming a line between two end points, using the Bresenham Line Draw Algorithm - 2D or 3D lines

Example

import smilPython as sp
# first and last points in a 3D image
pi = sp.IntPoint(0, 0, 0)
pf = sp.IntPoint(60, 50, 10)
line = sp.Bresenham(pi, pf)
# grab each point and print it
for i in range(0, line.nbPoints()):
pt = line.getPoint(i)
print(" {:2d} - {:3d} {:3d} {:3d}".format(i, pt.x, pt.y, pt.z))
# get a vector of points and set them in an image
im = sp.Image(64, 64, 12)
pts = line.getPoints()
for i in range(0, len(pts)):
im.setPixel(pts[i].x, pts[i].y, pts[i].z, 255)
im.show()
See also

#include <DImageDraw.h>

+ Inheritance diagram for Bresenham:
+ Collaboration diagram for Bresenham:

Public Member Functions

 Bresenham (const IntPoint &pi, const IntPoint &pf)
 Constructor : build a line (2D or 3D) with extremities pi and pf
 
 Bresenham (const IntPoint &pf)
 Constructor : build a line (2D or 3D) with extremities the origin and pf
 
 Bresenham (int xi, int yi, int zi, int xf, int yf, int zf)
 Constructor : build a 3D line defined by the coordinates of extremities.
 
 Bresenham (int xi, int yi, int xf, int yf)
 Constructor : build a 2D line defined by the coordinates of extremities.
 
vector< IntPointgetPoints () const
 getPoints() - access a vector with the points of the line
 
IntPoint getPoint (UINT i)
 getPoint() -
 
size_t nbPoints ()
 nbPoints() - the number of pixels in the line
 
double length ()
 length() - length of the line (Euclidean distance between extremities)
 

Constructor & Destructor Documentation

◆ Bresenham() [1/4]

Bresenham ( const IntPoint pi,
const IntPoint pf 
)
inline

Constructor : build a line (2D or 3D) with extremities pi and pf

Parameters
[in]pi: initial point
[in]pf: final point

◆ Bresenham() [2/4]

Bresenham ( const IntPoint pf)
inline

Constructor : build a line (2D or 3D) with extremities the origin and pf

Parameters
[in]pf: final point

◆ Bresenham() [3/4]

Bresenham ( int  xi,
int  yi,
int  zi,
int  xf,
int  yf,
int  zf 
)
inline

Constructor : build a 3D line defined by the coordinates of extremities.

Parameters
[in]xi,yi,zi: coordinates of initial point
[in]xf,yf,zf: coordinates of final point

◆ Bresenham() [4/4]

Bresenham ( int  xi,
int  yi,
int  xf,
int  yf 
)
inline

Constructor : build a 2D line defined by the coordinates of extremities.

Parameters
[in]xi,yi: coordinates of initial point
[in]xf,yf: coordinates of final point

Member Function Documentation

◆ getPoints()

vector< IntPoint > getPoints ( ) const
inline

getPoints() - access a vector with the points of the line

Returns
a vector with the points of the line

◆ getPoint()

IntPoint getPoint ( UINT  i)
inline

getPoint() -

Parameters
[in]i: the index of the point to be accessed

◆ nbPoints()

size_t nbPoints ( )
inline

nbPoints() - the number of pixels in the line

Returns
- the number of pixels

◆ length()

double length ( )
inline

length() - length of the line (Euclidean distance between extremities)

Returns
line length

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