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
|
|
| 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< IntPoint > | getPoints () 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)
|
|