libsxbp  v0.27
Experimental generation of 2D spiralling lines based on input binary data.
Functions
plot.h File Reference

This compilation unit provides functions for plotting and caching the points which make up the lines of a spiral. More...

#include <stddef.h>
#include "saxbospiral.h"
Include dependency graph for plot.h:

Go to the source code of this file.

Functions

size_t sxbp_sum_lines (sxbp_spiral_t spiral, size_t start, size_t end)
 Calculates the sum of all line lengths in this spiral within the given start and end indexes. More...
 
sxbp_status_t sxbp_spiral_points (sxbp_spiral_t spiral, sxbp_co_ord_array_t *output, sxbp_co_ord_t start_point, size_t start, size_t end)
 Calculates a series of co-ords for which trace a given part of a spiral line. More...
 
sxbp_status_t sxbp_cache_spiral_points (sxbp_spiral_t *spiral, size_t limit)
 Caches any uncached co-ords of the line of a spiral up to a given line index. More...
 

Detailed Description

This compilation unit provides functions for plotting and caching the points which make up the lines of a spiral.

Author
Joshua Saxby <joshua.a.saxby+TNOPLuc8vM==.com
Date
2016, 2017

Function Documentation

sxbp_status_t sxbp_cache_spiral_points ( sxbp_spiral_t *  spiral,
size_t  limit 
)

Caches any uncached co-ords of the line of a spiral up to a given line index.

If there are any outstanding co-ordinates which haven't been stored in the spiral's internal cache, then these will be calculated and stored in the cache. Subsequent identical calls will not incur the overhead of re-calculating these co-ords, provided the lengths of any of the spiral's lines are not changed in the process.

Parameters
[in,out]spiralThe spiral for which co-ords should be cached.
limitThe highest index of line for which co-ords should be cached to.
Returns
SXBP_OPERATION_OK on success.
SXBP_MALLOC_REFUSED on memory allocation failure.
Note
Asserts:
  • That spiral->lines is not NULL
  • That limit is less than or equal to spiral->size
sxbp_status_t sxbp_spiral_points ( sxbp_spiral_t  spiral,
sxbp_co_ord_array_t *  output,
sxbp_co_ord_t  start_point,
size_t  start,
size_t  end 
)

Calculates a series of co-ords for which trace a given part of a spiral line.

The whole spiral may be calculated, or just a given segment of it. This is controlled by specifying which line to start at and which to end at.

Parameters
spiralThe spiral for which line co-ords should be calculated.
[out]outputThe co-ords array which calculated co-ords should be written to.
start_pointThe x/y co-ordinates at which the line being plotted originates at.
startThe index of the first line which makes up the segment which is being calculated.
endThe index of the line after the last line which makes up the segment which is being calculated.
Returns
SXBP_OPERATION_OK on success.
SXBP_MALLOC_REFUSED on memory allocation failure.
Note
For this function to do anything useful, the spiral should at least have some line lengths calculated, but this is not essential.
Asserts:
  • That output->items is NULL
  • That start and end indexes are less than or equal to the spiral size
  • That spiral.lines is not NULL
Todo:
Might also need to add an assertion to check that end is never less than start.
size_t sxbp_sum_lines ( sxbp_spiral_t  spiral,
size_t  start,
size_t  end 
)

Calculates the sum of all line lengths in this spiral within the given start and end indexes.

params start and end specify the range of line indexes to use for the lines which are to be summed. These are inclusive of the lower bound but exclusive of the upper bound.

Parameters
spiralThe spiral of which line lengths should be summed.
startThe index of the first line to include in those of which lengths should be summed.
endThe index of the line after the last line to include in those of which lengths should be summed.
Returns
The sum of the lengths of all the lines in the given range.
Note
Asserts:
  • That start and end indexes are less than or equal to the spiral size
  • That spiral.lines is not NULL
Todo:
Might also need to add an assertion to check that end is never less than start.