Ask Your Question
0

Preserving aspect ratio in animation

asked 2015-03-30 16:34:56 -0500

Jeff Ford gravatar image

updated 2015-03-30 20:24:44 -0500

kcrisman gravatar image

I'm trying to animate a series of increasing, nested tori. I'm testing the code for the first one, but the aspect ratio isn't behaving, and axes are showing up. I've tried messing with figsize, to no avail. Suggestions?

u,v = var('u,v')
def is_even(n):
    return n%2 == 0

def c(n):
   return 2/3*(4^(n+1)-4)

def torus(n,u,v):
   if is_even(n):
        return [(2*4**n + 4**n*cos(u))*cos(v), (2*4**n + 4**n*cos(u))*sin(v) + c(n), 4**n*sin(u)]
    else:
        return [4**n*sin(u), (2*4**n + 4**n*cos(u))*sin(v) + c(n),  (2*4**n + 4**n*cos(u))*cos(v)]

T = []

for i in range(10):
    T.append(parametric_plot3d(torus(0,u,v), (u,0,(i+1)*2*pi/9), (v,0,(i+1)*2*pi/9), axes="false"))

a = animate(T)
a.show()
edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
1

answered 2015-03-31 15:26:01 -0500

eric_g gravatar image

updated 2015-03-31 15:32:24 -0500

To not depict the axes, you should use axes=False instead of axes="false". Also you may consider adding frame=False to suppress the bounding boxes. Taking into account kcrisman's suggestion aspect_ratio=1, you command should become

T.append(parametric_plot3d(torus(0,u,v), (u,0,(i+1)*2*pi/9), (v,0,(i+1)*2*pi/9), aspect_ratio=1, axes=False, frame=False))

However, there is still the issue that the bounds are not the same for each plot...

edit flag offensive delete link more
0

answered 2015-03-31 15:35:36 -0500

Jeff Ford gravatar image

I incorporated the suggestions and worked the bounds into two different loops. Seems to have fixed it.

u,v = var('u,v')

def is_even(n):
    return n%2 == 0

def c(n):
    return 2/3*(4^(n+1)-4)

def torus(n,u,v):
    if is_even(n):
        return [(2*4**n + 4**n*cos(u))*cos(v), (2*4**n + 4**n*cos(u))*sin(v)+c(n), 4**n*sin(u)]
    else:
        return [4**n*sin(u), (2*4**n + 4**n*cos(u))*sin(v)+c(n),  (2*4**n + 4**n*cos(u))*cos(v)]
T0 = []
for i in srange(0,2*pi+0.1, 0.1):
    T0.append(parametric_plot3d(torus(0,u,v), (u,0,2*pi),(v,i, i+0.1), aspect_ratio=1, frame=False, axes=False))

T = []    
for i in range(len(T0)):
    T.append(sum(T0[j] for j in range(i)))

a = animate(T)
a.show()
edit flag offensive delete link more
0

answered 2015-03-30 20:54:28 -0500

kcrisman gravatar image

I think part of your problem is that your bounds for the plots are not the same, but I'm not sure there is an easy way to make the bounds work that way in a parametric plot. Maybe you can pad it with an 'invisible' part?

However, putting aspect_ratio=1 in the plot command seems to help once the torus has worked its way around some of the way.

edit flag offensive delete link more

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: 2015-03-30 16:34:56 -0500

Seen: 118 times

Last updated: Mar 31 '15