My project that involves antenna design, in which Python generates the .nec file that allows me to model fractal antennas in the software and optimize them for the best performance. The program is intended to work with multiple fractal antennas, including all of the following:
- Koch Curve
- Hilbert Curve
- Koch Snowflake
Don’t worry, this isn’t a homework assignment. I am giving a speech on Fractal Antennas and wanted to automate the design process, otherwise it is tedious.
Unfortunately, I’m having trouble with calculating the center point of the Koch Curve. Here is an image of what it looks like in software; note that I still geometry bugs that need to be solved.

Here are the coordinates of the resulting Python script using a iteration level of 3 and segment size of 0.305m.
The Python scripts that is currently being subjugated to my madness are pointed out below:
As you will notice in the image depiction of the Koch Curve, it is off center by a tiny amount. My equation to find the complete length is this:

Where:
l = total side-length (referenced from the bottom) of the Koch Curve
s = segment size (my segment size was 0.305m, they should all be equal)
n = number of iterations
Does anyone know why I’m not getting the center?
Thanks,
Austin
Perhaps you should try to reimplement your iterative calculation being more canonical.
An answer to a request for a good Koch Curve algorithm in Python is here:
Implementing the Koch Curve?
(and also the original code in the question could help you a lot)
EDIT:
I created a script which uses code from the provided link, plus Cairo and Python Image Library (PIL) to render an image. Hope it helps: