Ask Your Question
1

Sage code for making fractal pictures

asked 2021-02-24 07:24:32 +0200

anonymous user

Anonymous

updated 2021-02-24 18:35:18 +0200

slelievre gravatar image

I am a person who makes math problems by coding in Korea.

I need to write a question (about geometric sequences) using pictures, but I don't know how to make them.

Fractal from circle and diagonals in a square

Fractal from shaded region bounded by circle arcs in a disc

I know it's difficult to tell all of them, but I would appreciate pointers to related sources or examples.

edit retag flag offensive close merge delete

Comments

I don' know why https:// were missing in front of the two url ?.

first image

second image

ortollj gravatar imageortollj ( 2021-02-24 17:41:32 +0200 )edit

Edited the question to turn the urls into image links. Not sure how to rotate by a quarter turn. Maybe the original poster can upload rotated pictures somewhere.

slelievre gravatar imageslelievre ( 2021-02-24 18:32:04 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2021-02-24 16:35:20 +0200

Juanjo gravatar image

The following code may help to get one of the pictures:

def figure(c,r,z):
    fig = circle((c,0), r, facecolor="white", edgecolor="black", fill=True, zorder=z)
    fig += disk((c+r/3,0), 2*r/3, (0,pi), color="lightgray", zorder=z+1)
    fig += arc((c+r/3,0), 2*r/3, sector=(0,pi), color="black", zorder=z+1)
    fig += disk((c-r/3,0), 2*r/3, (pi,2*pi), color="lightgray", zorder=z+1)
    fig += arc((c-r/3,0), 2*r/3, sector=(pi,2*pi), color="black", zorder=z+1)
    fig += disk((c+2*r/3,0), r/3, (0,pi), color="white", zorder=z+2)
    fig += arc((c+2*r/3,0), r/3, sector=(0,pi), color="black", zorder=z+2)
    fig += disk((c-2*r/3,0), r/3, (pi,2*pi), color="white", zorder=z+2)
    fig += arc((c-2*r/3,0), r/3, sector=(pi,2*pi), color="black", zorder=z+2)
    fig += line([(c-r,0),(c+r,0)], color="black", zorder=z+2)
    return fig
centers = [[2/3], [4/9, 8/9], [10/27,14/27,22/27,26/27]]
radii = [1/3, 1/9, 1/27]
zs = [5, 10, 15]
r = 3
R = figure(0,r,0)
show(R, axes=False)
for i in [0,1,2]:
    for c in centers[i]:
        R += figure(-c*r,radii[i]*r,zs[i]) + figure(c*r,radii[i]*r,zs[i])
    show(R, axes=False)

See this SageMath cell for the output.

edit flag offensive delete link more

Comments

thank you !!!!!!

wnghks2516 gravatar imagewnghks2516 ( 2021-02-25 10:32:15 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-02-24 07:24:32 +0200

Seen: 82 times

Last updated: Feb 24