ifsgr

ifsgr — Basic definitions and miscellaneous functions.

Synopsis




#define     IFS_EPSILON
#define     IFS_PROBSTACK_BITS
#define     IFS_PROBSTACK
#define     IFS_PROBSTACK_MASK
typedef     PointXY;
typedef     IFSTrans;
typedef     IFS;
size_t*     ifs_discretize_probability      (const IFS *ifs,
                                             size_t ntab,
                                             size_t *tab);
void        ifs_find_range                  (const IFS *ifs,
                                             const size_t *tab,
                                             uint64_t niter,
                                             PointXY *min,
                                             PointXY *max);
void        ifs_free                        (IFS *ifs);
void        ifs_normalize_probabilities     (IFS *ifs);

Description

Details

IFS_EPSILON

#define IFS_EPSILON 1e-9

A small number (much smaller than 1 and much larger than machine epsilon).


IFS_PROBSTACK_BITS

#define IFS_PROBSTACK_BITS 11

The number of bits needed to represent indices in precomputed probability maps used in IFS drawing functions.


IFS_PROBSTACK

#define IFS_PROBSTACK (1UL << (IFS_PROBSTACK_BITS))

The size of precomputed probability maps used in IFS drawing functions.


IFS_PROBSTACK_MASK

#define IFS_PROBSTACK_MASK (IFS_PROBSTACK - 1UL)

Mask for clearing all but the lowest IFS_PROBSTACK_BITS bits in an integer.


PointXY

typedef struct {
    double x, y;
} PointXY;

Cartesian coordinates of a point in plane.


IFSTrans

typedef struct {
    double x, y;
    double xx, xy, yx, yy;
    double p;
} IFSTrans;

Structure representing an affine two-dimensional transformation.


IFS

typedef struct {
    char     *name;
    size_t    n;
    IFSTrans *t;
} IFS;

Structure representing an iterated function system.


ifs_discretize_probability ()

size_t*     ifs_discretize_probability      (const IFS *ifs,
                                             size_t ntab,
                                             size_t *tab);

Computes transformation relative occurrence table.

Index of each transformation is present proportionally to the transformation probability. To select a random transformation with corresponding probability is thus sufficient to select a random item from the table.

ifs: An Iterated Function System.
ntab: The size of ntab.
tab: Array to store the precomputed transformation relative occurrence table to, or NULL to allocate a new one.
Returns : tab itself it it was not NULL, a newly allocated array which should be freed when no longer needed otherwise.

ifs_find_range ()

void        ifs_find_range                  (const IFS *ifs,
                                             const size_t *tab,
                                             uint64_t niter,
                                             PointXY *min,
                                             PointXY *max);

Find the rectangle to which the fractal ifs fits in.

This is done simply by computing a few thousand iterations.

ifs: An Iterated Function System.
tab: Precomputed probability table of size IFS_PROBSTACK.
niter: The number of iterations to try, when zero some reasonable built-in default is used.
min: Where the minimum coordinates should be stored.
max: Where the maximum coordinates should be stored.

ifs_free ()

void        ifs_free                        (IFS *ifs);

Completely frees an IFS structure.

ifs: An Iterated Function System.

ifs_normalize_probabilities ()

void        ifs_normalize_probabilities     (IFS *ifs);

Normalize probabilitites to sum 1.0 keeping their ratios.

ifs: An Iterated Function System.