Affine Functions

Home • Gallery • Tutorials • Download • Purchase • Site Map
 

Affine Functions Support

The Fractal Science Kit fractal generator Affine functions are associated with the Affine object:

Object Affine { A : B : C : D : E : F }

The fields A, B, C, D, E, and F are real numbers that define an Affine Transformation.

The following example illustrates how you would define a Affine object using the object's constructor:

Affine t = Affine(A, B, C, D, E, F)

This example assigns an affine transformation to the variable t. The affine transformation is defined by the arguments: A, B, C, D, E, and F, passed to the constructor.

'
' Geometric constructor for Affine objects.
'
'   r - horizontal scale and reflection (negative values)
'   s - vertical scale and reflection (negative values)
'   theta - horizontal rotation
'   phi - vertical rotation
'   e - translation in X
'   f - translation in Y
'
Affine Affine.Create(r, s, theta, phi, e, f) {
  a =  r * Cos(theta)
  b = -s * Sin(phi)
  c =  r * Sin(theta)
  d =  s * Cos(phi)
  return Affine(a, b, c, d, e, f)
}

Affine.Create is an alternate constructor for a Affine object using a set of geometric arguments.

Affine Affine.Identity()
Affine Affine.Inverse(Affine a)
Complex Affine.Determinate(Affine a)
void Affine.InitializeAffineArray(Affine a[], count)
Complex Affine.IsIdentity(Affine a)

Affine.Identity returns the identity affine transformation. Affine.Inverse returns the inverse of transformation a. Affine.Determinate returns the determinate of the affine transformation. Affine.InitializeAffineArray assigns the identity affine transformation to the first count items in the affine transformation array a[]. Affine.IsIdentity returns True if the transformation a is the identity transformation, and False otherwise.

Complex Affine.TransformPoint(Affine a, z)
Complex Affine.InverseTransformPoint(Affine a, z)

Affine.TransformPoint applies affine transformation a to the point z and returns the resulting point. Affine.InverseTransformPoint applies the inverse of affine transformation a to the point z and returns the resulting point.

Affine Affine.Multiply(Affine a1, Affine a2)
Affine Affine.Multiply3(Affine a1, Affine a2, Affine a3)
Affine Affine.Multiply4(Affine a1, Affine a2, Affine a3, Affine a4)
Affine Affine.MultiplyArray(Affine a[], count)
void Affine.ArrayMultiply(Affine a1[], Affine a2[], count, Affine result[])
void Affine.MultiplyNxM(Affine a1[], Affine a2[], Affine result[])
Affine Affine.Power(Affine a, power)
void Affine.GeneratePowers(Affine a, count, Affine pow[])

Affine.Multiply returns the product of affine transformations a1 and a2. Affine.Multiply3 returns the product of the 3 affine transformations a1, a2, and a3. Affine.Multiply4 returns the product of the 4 affine transformations a1, a2, a3, and a4. Affine.MultiplyArray returns the product of the count affine transformations in array a[]. Affine.ArrayMultiply generates an array of the transformations in result[] with the product of corresponding transformations in a1[] and a2[]. All 3 arrays should be dimensioned count. Affine.MultiplyNxM generates an array of the transformations in result[] with the product of each of the transformations in a1[] with each of the transformations in a2[]. result[] is automatically dimensioned N*M where N is the dimension of a1[] and M is the dimension of a2[]. Affine.Power multiplies affine transformation a by itself power times and returns the result. Affine.GeneratePowers fills the array pow[] with count powers of the Affine transformation a. Array pow[] should be dimensioned count.

void Affine.Translate(byref Affine a, shift)
void Affine.TranslateXY(byref Affine a, Tx, Ty)
void Affine.TranslateX(byref Affine a, Tx)
void Affine.TranslateY(byref Affine a, Ty)

Affine.Translate injects a translation to the point shift into affine transformation a. Affine.TranslateXY injects a translation by Complex(Tx,Ty) into affine transformation a. Affine.TranslateX injects a translation by Complex(Tx,0) into affine transformation a. Affine.TranslateY injects a translation by Complex(0,Ty) into affine transformation a.

void Affine.Rotate(byref Affine a, angle)
void Affine.RotateAboutPoint(byref Affine a, point, angle)

Affine.Rotate injects a rotation by angle radians into affine transformation a. Affine.RotateAboutPoint injects a rotation by angle radians about point into affine transformation a.

void Affine.Scale(byref Affine a, S)
void Affine.ScaleAboutPoint(byref Affine a, point, S)
void Affine.ScaleXY(byref Affine a, Sx, Sy)
void Affine.ScaleX(byref Affine a, Sx)
void Affine.ScaleY(byref Affine a, Sy)

Affine.Scale injects a magnification by factor S into affine transformation a. If S is complex, the S.x and S.y components are used as independent scale factors for X and Y, otherwise, S is applied to both dimensions.  Affine.ScaleAboutPoint injects a magnification by factor S about point into affine transformation a. Affine.ScaleXY injects a magnification by factor Complex(Sx,Sy) into affine transformation a. Affine.ScaleX injects a magnification by factor Complex(Sx,1) into affine transformation a. Affine.ScaleY injects a magnification by factor Complex(1,Sy) into affine transformation a.

void Affine.ShearX(byref Affine a, Sx)
void Affine.ShearY(byref Affine a, Sy)

Affine.ShearX injects a shear in X by Sx into affine transformation a. Affine.ShearY injects a shear in Y by Sy into affine transformation a.

void Affine.ReflectAboutXAxis(byref Affine a)
void Affine.ReflectAboutYAxis(byref Affine a)
void Affine.ReflectAboutPositiveDiagonal(byref Affine a)
void Affine.ReflectAboutNegativeDiagonal(byref Affine a)
void Affine.Reflect(byref Affine a, angle)
void Affine.ReflectAboutLine(byref Affine a, point, angle)

Affine.ReflectAboutXAxis injects a reflection about the X axis into affine transformation a. Affine.ReflectAboutYAxis injects a reflection about the Y axis into affine transformation a. Affine.ReflectAboutPositiveDiagonal injects a reflection about the line y=x into affine transformation a. Affine.ReflectAboutNegativeDiagonal injects a reflection about the line y=-x into affine transformation a. Affine.Reflect injects a reflection about the line through the origin inclined angle radians with respect to the X axis into affine transformation a. Affine.ReflectAboutLine injects a reflection about the line through point inclined angle radians with respect to the X axis into affine transformation a.

Affine Affine.Map3(p1, p2, p3)
Affine Affine.Map3to3(p1, p2, p3, q1, q2, q3)
Affine Affine.MapTriangletoTriangle(Triangle t1, Triangle t2)

Affine.Map3 returns the unique affine transformation that maps the points 0, 1, and 1i to z1, z2, and z3, respectively. Affine.Map3to3 returns the unique affine transformation that maps the points p1, p2, and p3, to q1, q2, and q3, respectively. Affine.MapTriangletoTriangle returns the unique affine transformation that maps triangle t1 to triangle t2.

void Affine.GenerateIFS(Affine a[], N, Affine result[])
void Affine.GenerateIFS2(Affine a[], N, Affine result[], Complex depth[])

Affine.GenerateIFS generates a set of affine transformations in result[]. Each transformation in result[] is generated by multiplying together N transformations in a[], to form a composite transformation. Affine.GenerateIFS2 generates a set of affine transformations in result[]. Each transformation in result[] is generated by multiplying together 0 or more transformations in a[], to form a composite transformation. The number of transformations range from 0 to N. depth[i] is the number of transformations used to form result[i]. depth[i] is a value between 0 and N.

'
' Generate a random contraction map.
'
' To be a contraction map, the affine transformation
' coefficients must satisfy the following conditions:
'
'   a^2 + c^2 < 1
'   b^2 + d^2 < 1
'   a^2 + b^2 + c^2 + d^2 < 1 + (a*d - c*b)^2
'
Affine Affine.RandomContractionMap(center, radius)

Affine.RandomContractionMap returns a random contraction map as described in the comments.

void Affine.InitializeWeights(Affine s[], w[], count)
void Affine.InitializeWeights2(Affine s[], w[], count)

These methods initialize the weights w[] associated with the count affine transformations given in s[]. The weights are used as probabilities when generating the IFS fractal based on the affine transformations.

Affine.InitializeWeights sets the values in the array w[] to a weighted average using the value of the determinate of each transformation as the weight; i.e., w[i] is set to determinate/sum, where determinate is the determinate of s[i] and sum is the sum of the determinates of all elements in s[]. This method of assigning the probabilities has been popularized by Michael F. Barnsley and is described in the book Chaos and Fractals by Peitgen, Jurgens, Saupe, Section 6.3 pages 327-329.

Affine.InitializeWeights2 sets the values in the array w[] using an algorithm described in the paper A Multifractal Analysis of IFSP Invariant Measures With Application to Fractal Image Generation by J. M. Gutierrez, A. Iglesias, and M. A. Rodriguez.

void Affine.ScaleDimension(Affine s[], count, scale)

Affine.ScaleDimension can be used to sharpen/blur the IFS fractal associated with the count affine transformations given in s[] without changing its general shape. Use scale less than 1 (e.g., 0.9) to sharpen the fractal and scale greater than 1 (e.g., 1.1) to blur the fractal.

void Affine.GenerateSymmetryTransformationPoints( \
  SymmetryTransformationInfo symmetryArray[], \
  Affine s[], \
  count, \
  z \
)

Affine.GenerateSymmetryTransformationPoints sets the Point field for each of the count objects in the symmetryArray[] array by applying the associated affine transformation in s[] to z. This is used to implement a Symmetry Transformation based on an array of affine transformations.

 

Copyright © 2004-2016 Hilbert, LLC
All rights reserved