Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6563777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:53:19+00:00 2026-05-25T13:53:19+00:00

My project that involves antenna design, in which Python generates the .nec file that

  • 0

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.

Koch Fractal in 4NEC2

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:

.NEC File

Coordinates

4NEC2_Generator.py Code

Complete Project

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:

Center Point Equation

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:53:20+00:00Added an answer on May 25, 2026 at 1:53 pm

    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:

    #!/bin/env python
    # coding: utf-8
    
    import math
    
    angles = [math.radians(60*x) for x in range(6)]
    sines = [math.sin(x) for x in angles]
    cosin = [math.cos(x) for x in angles]
    
    def L(angle, coords, jump):
        return (angle + 1) % 6
    def R(angle, coords, jump):
        return (angle + 4) % 6
    def F(angle, coords, jump):
        coords.append(
            (coords[-1][0] + jump * cosin[angle],
             coords[-1][1] + jump * sines[angle]))
        return angle
    
    decode = dict(L=L, R=R, F=F)
    
    def koch(steps, length=200, startPos=(0,0)):
        pathcodes="F"
        for i in xrange(steps):
            pathcodes = pathcodes.replace("F", "FLFRFLF")
    
        jump = float(length) / (3 ** steps)
        coords = [startPos]
        angle = 0
    
        for move in pathcodes:
            angle = decode[move](angle, coords, jump)
    
        return coords
    
    
    TOTALWIDTH = 1000
    
    points = koch(3,TOTALWIDTH,(-TOTALWIDTH/2,0))
    print points
    
    
    # optional part, shows an image with Y axis(good for debugging)
    import cairo, Image
    
    width = TOTALWIDTH
    height = int(TOTALWIDTH*0.32)
    surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
    cr = cairo.Context(surface)
    cr.set_source_rgb(1,1,1)
    cr.rectangle(0, 0, width, height)
    cr.fill()
    cr.translate(width*0.5, height*0.95)
    cr.scale(1, -1)
    
    # red Y axis:
    cr.set_source_rgb(1,0,0)
    cr.move_to(0,0)
    cr.line_to(0,300)
    cr.stroke()
    
    cr.set_source_rgb(0,0,0)
    cr.set_line_width(0.5)
    cr.move_to(*points[0])
    for n in range(len(points)):
        cr.line_to(*points[n])
    cr.stroke()
    
    im = Image.frombuffer("RGBA", (width, height), surface.get_data(), "raw", "BGRA", 0,1)
    im.show()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a project that involves an embedded system which runs a
I'm working on a small project that involves grabbing a list of contacts which
I'm working on a project that involves writing low-level C software for a hardware
I have a project that involves polling a hardware switch each update and converting
I'm starting a project that involves writing mailets for Apache James . As far
I'm working on a home project that involves comparing images to a database of
I am currently undertaking a project that involves extensive use of Java RMI and
I'm starting a new project that involves users paying to see educational videos. These
I'm working on a project that involves converting a large amount of HTML content
I'm working on a small project that involves me loading an image into a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.