#include <sadie.h>
#include <math.h>
#include "logerr.h"
#include "bresenham.h"
Go to the source code of this file.
Typedefs | |
typedef int64_t | bcoord_t |
An integer of at least 33 bits: holds any signed OR unsigned 32 bit int. | |
typedef bcoord_t(* | coord_accessorp_t )(bresenham_linep_t bline) |
A coordinate accessor function. | |
typedef void(* | point_iteratorp_t )(bresenham_linep_t bline) |
A point iterator function. | |
Functions | |
bresenham_linep_t | bresenham_from_s_coord (int32_t first_col, int32_t first_row, int32_t last_col, int32_t last_row) |
Wrapper to construct a Bresenham line context from signed coordinates. | |
bresenham_linep_t | bresenham_from_coord (uint32_t first_col, uint32_t first_row, uint32_t last_col, uint32_t last_row) |
Wrapper to construct a Bresenham line context from unsigned coordinates. | |
int | bresenham_next (bresenham_linep_t bline, uint32_t *col, uint32_t *row) |
Iterate the Bresenham line context, generating the next coordinate pair. | |
int | bresenham_next_s (bresenham_linep_t bline, int32_t *col, int32_t *row) |
Iterate the Bresenham line context, generating the next coordinate pair. | |
void | demolish_bresenham (bresenham_linep_t *blinehandle) |
Destroy a Bresenham line context. |
Many different web resources reference a web page by Colin Flanagan, currently hosted at http://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html which is a very lucid description of the derivation of the algorithm. Remember that here we're using row & column notation rather than left-handed Cartesian x,y coordinates, but in any case we define arbitrary internal coordinates, that get mapped to rows and columns as needed. The original reference is: Bresenham, J.E. (1965) "Algorithm for computer control of a digital plotter". IBM Systems Journal 4(1) 1965, p. 25--30.
Definition in file bresenham.c.
|
Wrapper to construct a Bresenham line context from unsigned coordinates. The context records the state of the algorithm that will generate pairs of discrete coordinates for a series of steps approximating the line linking the first and last points.
Definition at line 279 of file bresenham.c. |
|
Wrapper to construct a Bresenham line context from signed coordinates. The context records the state of the algorithm that will generate pairs of discrete coordinates for a series of steps approximating the line linking the first and last points.
Definition at line 260 of file bresenham.c. Referenced by Sadie_Plot_ProfileCmd(). |
|
Iterate the Bresenham line context, generating the next coordinate pair. As constructed, the line context will always represent at least one point (even if the first point coincides with the last point), and so we can iterate it at least once; however once we've obtained the coordinates of the last point further iterations are incorrect (think of the context as being just off the end of the line). An iteration produces the current coordinate pair in the sequence of discrete points that approximate the straight line joining the first to the last point, and modifies the internals of the context to prepare the next point. The return value is a Boolean flag that is false iff further iterations are possible.
Definition at line 303 of file bresenham.c. References logerr_assert, LOGERR_DEBUG, and LOGERR_FUNC. Referenced by Sadie_Plot_ProfileCmd(). |
|
Iterate the Bresenham line context, generating the next coordinate pair. Just a variation for signed coordinates.
Definition at line 332 of file bresenham.c. References logerr_assert, LOGERR_DEBUG, and LOGERR_FUNC. |
|
Destroy a Bresenham line context. A simple free() would suffice to reclaim the storage allocated by the current Bresenham line context constructors, but we don't want to guarantee this for all future versions of this code.
Definition at line 359 of file bresenham.c. References logerr_assert, LOGERR_CRIT, and LOGERR_FUNC. Referenced by Sadie_Plot_ProfileCmd(). |