![]() | ![]() | IFSgr Library Reference Manual | ![]() |
---|
trans — Trasforming IFSes and individual trasformations.
void ifs_fix_transforms (IFS *ifs, PointXY min, PointXY max, double ratio); void ifs_flip_horizontally (IFS *ifs); void ifs_flip_vertically (IFS *ifs); void ifs_move (IFS *ifs, PointXY shift); void ifs_reflect (IFS *ifs, double omega); void ifs_rotate (IFS *ifs, double phi); void ifs_scale (IFS *ifs, double r); void ifs_skew (IFS *ifs, double k); void ifs_asymmetrize (IFS *ifs, double alpha); void ifs_transform (IFS *ifs, const IFSTrans *tt); void ifs_trans_asymmetrize (IFSTrans *t, double alpha); IFSTrans* ifs_trans_compose (const IFSTrans *t1, const IFSTrans *t2, IFSTrans *t); void ifs_trans_flip_horizontally (IFSTrans *t); void ifs_trans_flip_vertically (IFSTrans *t); PointXY ifs_trans_get_fixed_point (const IFSTrans *t); PointXY ifs_trans_get_rotations (const IFSTrans *t); PointXY ifs_trans_get_scales (const IFSTrans *t); bool ifs_trans_is_contraction (const IFSTrans *t); void ifs_trans_move (IFSTrans *t, PointXY shift); void ifs_trans_reflect (IFSTrans *t, double omega); void ifs_trans_rotate (IFSTrans *t, double phi); IFSTrans* ifs_trans_rsr_compose (PointXY pq, PointXY phi, IFSTrans *t); void ifs_trans_scale (IFSTrans *t, double r); void ifs_trans_skew (IFSTrans *t, double k); void ifs_trans_transform (IFSTrans *t, const IFSTrans *tt); IFSTrans* ifs_trans_init_identity (IFSTrans *t); IFSTrans* ifs_trans_init_rotation (IFSTrans *t, double phi); IFSTrans* ifs_trans_init_scaling (IFSTrans *t, double sx, double sy); IFSTrans* ifs_trans_init_skew (IFSTrans *t, double k);
Each trasforming function comes in two flavours: one transforming a signle transformation, other transforming a complete iterated function system. ifs_trans_transform() and ifs_transform() can transform by arbitrary (regular) affine transformation, but try to avoid them and use the special-case functions if you can, as they are simplier, faster and less prone to rounding errors.
void ifs_fix_transforms (IFS *ifs, PointXY min, PointXY max, double ratio);
Transforms the transformations to fit the fractal to [0,1]x[0,1] square.
ifs: | An Iterated Function System. |
min: | The minimum bounding coordinates. |
max: | The maximum bounding coordinates. |
ratio: | The requested size, may be different from 1, but the fractal is always centered on [0.5,0.5]. |
void ifs_flip_horizontally (IFS *ifs);
Flip the IFS ifs about the y axis (i.e., horizontally).
ifs: | An Iterated Function System. |
void ifs_flip_vertically (IFS *ifs);
Flip the IFS ifs about the x axis (i.e., vertically).
ifs: | An Iterated Function System. |
void ifs_move (IFS *ifs, PointXY shift);
Move the IFS ifs by the vector shift.
ifs: | An Iterated Function System. |
shift: | A vector. |
void ifs_reflect (IFS *ifs, double omega);
Reflect the IFS ifs about a general axis passing through origin.
ifs: | An Iterated Function System. |
omega: |
void ifs_rotate (IFS *ifs, double phi);
Rotate the IFS ifs by the angle phi around origin.
ifs: | An Iterated Function System. |
phi: | An angle (in radians). |
void ifs_scale (IFS *ifs, double r);
Scale the IFS ifs by a factor r.
ifs: | An Iterated Function System. |
r: | Scale factor. |
void ifs_skew (IFS *ifs, double k);
Skew x by y*k in the IFS ifs.
ifs: | An Iterated Function System. |
k: | Skew. |
void ifs_asymmetrize (IFS *ifs, double alpha);
Asymmetrize x/y ratio of IFS ifs by alpha squared.
ifs: | An Iterated Function System. |
alpha: | Asymmetrization amount. |
void ifs_transform (IFS *ifs, const IFSTrans *tt);
Transform ifs by tt.
Does not make sense when tt is singular.
ifs: | An Iterated Function System to be transformed. |
tt: | An affine transformation. |
void ifs_trans_asymmetrize (IFSTrans *t, double alpha);
Asymmetrize x/y ratio of transformation t by alpha squared.
t: | An affine transformation. |
alpha: | Asymmetrization amount. |
IFSTrans* ifs_trans_compose (const IFSTrans *t1, const IFSTrans *t2, IFSTrans *t);
Compose two affine transformations t1.t2 = t.
t1: | Left (second) transformation. |
t2: | Right (first) transformation. |
t: | Where the composition should be stored, or NULL to allocate a new transformation. |
Returns : | Either t itself (when non-NULL), or a newly allocated transformation that should be freed when no longer needed. |
void ifs_trans_flip_horizontally (IFSTrans *t);
Flip the transformation t about the y axis (i.e., horizontally).
t: | An affine transformation. |
void ifs_trans_flip_vertically (IFSTrans *t);
Flip the transformation t about the x axis (i.e., vertically).
t: | An affine transformation. |
PointXY ifs_trans_get_fixed_point (const IFSTrans *t);
Returns the fixed point of an affine transformation t.
t: | An affine transformation. |
Returns : | The fixed point of t. When t is [almost] a pure translation or reflection, HUGE_VAL is returned. |
PointXY ifs_trans_get_rotations (const IFSTrans *t);
Find the two rotations of the R2.S.R1 matrix decomposition of t.
Please see ifs_trans_get_scales() for details.
t: | An affine transformation. |
Returns : | The angles of the two rotations. The angle of R1 is in the x component, the angle of R2 is in the y component. |
PointXY ifs_trans_get_scales (const IFSTrans *t);
Find the two pure scaling factors of the R2.S.R1 matrix decomposition of t.
R2, R1 are pure rotations, S is a diagonal matrix. In other words, it finds the unique (up to pi/2 in the rotations) shear-free decomposition and returns the diagonal of S.
The pure scaling factors allow to determine easy whether a transformation is a contraction: the necessary and sufficient condition is that both are smaller than one in absolute value. However, if you only need to know whether a transformation is a contraction, use ifs_trans_is_contraction().
t: | An affine transformation. |
Returns : | The pure scaling factors, the x factor is always greater or equal than the y factor (and particularly the x factor is always nonnegative). |
bool ifs_trans_is_contraction (const IFSTrans *t);
Test whether affine transformation t is a contraction.
t: | An affine transformation. |
Returns : | True if t is contraction, false otherwise. |
void ifs_trans_move (IFSTrans *t, PointXY shift);
Move the transformation t by the vector shift.
t: | An affine transformation. |
shift: | A vector. |
void ifs_trans_reflect (IFSTrans *t, double omega);
Reflect the transformation t about a general axis passing through origin.
t: | An affine transformation. |
omega: |
void ifs_trans_rotate (IFSTrans *t, double phi);
Rotate the transformation t by the angle phi around origin.
t: | An affine transformation. |
phi: | An angle (in radians). |
IFSTrans* ifs_trans_rsr_compose (PointXY pq, PointXY phi, IFSTrans *t);
Composes transformation matrix back from R2.S.R1 decomposition pq, phi.
The translation and probability components are not defined.
pq: | Pure scaling factors from R2.S.R1 decomposition. |
phi: | Rotation angles from R2.S.R1 decomposition. |
t: | A affine transformation to modify, or NULL (a new transformation is allocated then). |
Returns : | Either t itself (when non-NULL), or a newly allocated transformation that should be freed when no longer needed. |
void ifs_trans_scale (IFSTrans *t, double r);
Scale the transformation t by a factor r.
t: | An affine transformation. |
r: | Scale factor. |
void ifs_trans_skew (IFSTrans *t, double k);
Skew x by y*k in the transformation t.
t: | An affine transformation. |
k: | Skew. |
void ifs_trans_transform (IFSTrans *t, const IFSTrans *tt);
Transform t by tt.
Does not make sense when tt is singular.
t: | An affine transformation to be transfromed. |
tt: | An affine transformation. |
IFSTrans* ifs_trans_init_identity (IFSTrans *t);
Initializes a transformation to identity, eventually creating it.
Transformation probability is not set.
t: | A transformation to be initialized to identity, or NULL to allocate a new one. |
Returns : | t if it isn't NULL; a newly allocated transformation otherwise. |
IFSTrans* ifs_trans_init_rotation (IFSTrans *t, double phi);
Initializes a transformation to rotation by phi counter-clokwise, eventually creating it.
Transformation probability is not set.
t: | A transformation to be initialized to rotation, or NULL to allocate a new one. |
phi: | The rotation angle. |
Returns : | t if it isn't NULL; a newly allocated transformation otherwise. |
IFSTrans* ifs_trans_init_scaling (IFSTrans *t, double sx, double sy);
Initializes a transformation to scaling by (sx, sy) eventually creating it.
Transformation probability is not set.
t: | A transformation to be initialized to scaling, or NULL to allocate a new one. |
sx: | Scaling in x direction. |
sy: | Scaling in y direction. |
Returns : | t if it isn't NULL; a newly allocated transformation otherwise. |
IFSTrans* ifs_trans_init_skew (IFSTrans *t, double k);
Initializes a transformation skew k eventually creating it.
Transformation probability is not set.
t: | A transformation to be initialized to skew, or NULL to allocate a new one. |
k: | The skew. |
Returns : | t if it isn't NULL; a newly allocated transformation otherwise. |
<< IFSgr Library Reference Manual | file >> |