I'm trying to write code that converts affine transformations from matrix form to angles and lengths to render fractals in chaotica. The resulting Fern however is too thin. It looks like the Barnsley Fern but more condensed and I'm wondering what I'm doing wrong. Initially the fern was upside down when using the original translation vector, but this was resolved after multiplying this vector with -1. I also offset the y angle by 90 degrees as this what the default vector in Chaotica has as y angle value.

The code is as follows:

`import numpy as np`

# Barnsley Fern affine transformations

# Format a b c d e f p -> [a, b// c, d][x//y]+[e//f] where p is the probability weight

function_set = [[0.0, 0.0, 0.0, 0.16, 0.0, 0.0, 0.01],

[0.85, 0.04, -0.04, 0.85, 0.0, 1.6, 0.85],

[0.2, -0.26, 0.23, 0.22, 0.0, 1.6, 0.07],

[-0.15, 0.28, 0.26, 0.24, 0.0, 0.44, 0.07]]

# Calculates the angle between two vectors in degrees

def angle(vector_1, vector_2):

vector_1 = np.array(vector_1)

vector_2 = np.array(vector_2)

# Calculate signed angle between vectors

# Using answer https://stackoverflow.com/questions/2150050/finding-signed-angle-between-vectors by Derek Ledbetter

angle = np.rad2deg(np.arctan2( vector_1[0]*vector_2[1] - vector_1[1]*vector_2[0], vector_1[0]*vector_2[0] + vector_1[1]*vector_2[1] ))

return angle

def affine_transformation(f, c0, c1):

x = c0 * f[0] + c1 * f[1]

y = c0 * f[2] + c1 * f[3]

return [x, y]

for i in range(len(function_set)):

# calculate length and angle for the unit square x vector

x = affine_transformation(function_set[i], 1, 0)

length_x = np.linalg.norm(x)

angle_x = angle(x, [1,0]) + 0

translation_x = -function_set[i][4]

# calculate length and angle for the unit square y vector

y = affine_transformation(function_set[i], 0, 1)

length_y = np.linalg.norm(y)

angle_y = angle(y, [0,1])

angle_y = angle_y + 90

translation_y = -function_set[i][5]

print("Length x: {}, angle x: {}, translation x: {}".format(length_y, angle_y, translation_y))

print("Length y: {}, angle y: {}, translation y: {}".format(length_x, angle_x, translation_x))

Does anyone know why this happens?

Linkback: https://fractalforums.org/noobs-corner/76/barnsley-fern-too-thin/3757/