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
pi = sp.IntPoint(0, 0, 0)
pf = sp.IntPoint(60, 50, 10)
line = sp.Bresenham(pi, pf)
for i in range(0, line.nbPoints()):
pt = line.getPoint(i)
print(" {:2d} - {:3d} {:3d} {:3d}".format(i, pt.x, pt.y, pt.z))
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
-
|
| Bresenham (const IntPoint &pi, const IntPoint &pf) |
| Constructor : build a line (2D or 3D) with extremities pi and pf More...
|
|
| Bresenham (const IntPoint &pf) |
| Constructor : build a line (2D or 3D) with extremities the origin and pf More...
|
|
| Bresenham (int xi, int yi, int zi, int xf, int yf, int zf) |
| Constructor : build a 3D line defined by the coordinates of extremities. More...
|
|
| Bresenham (int xi, int yi, int xf, int yf) |
| Constructor : build a 2D line defined by the coordinates of extremities. More...
|
|
vector< IntPoint > | getPoints () const |
| getPoints() - access a vector with the points of the line More...
|
|
IntPoint | getPoint (UINT i) |
| getPoint() - More...
|
|
size_t | nbPoints () |
| nbPoints() - the number of pixels in the line More...
|
|
double | length () |
| length() - length of the line (Euclidean distance between extremities) More...
|
|
void | printSelf (ostream &os=std::cout, string indent="") |
|
| BaseObject (const char *_className, bool _register=true) |
|
| BaseObject (const BaseObject &rhs, bool _register=true) |
|
BaseObject & | operator= (const BaseObject &rhs) |
|
Core * | getCoreInstance () |
|
virtual const char * | getInfoString (const char *="") const |
|
virtual void | printSelf (ostream &=std::cout, string="") const |
|
virtual const char * | getClassName () const |
|
virtual void | setName (const char *_name) |
|
virtual const char * | getName () const |
|
virtual size_t | getAllocatedSize () const |
|