# 221 - Quadric Surfaces

## 980 days ago by travis

# Ellipsoid @interact def ellipsoid(a=slider(1,5,step_size=0.2,default=3), b=slider(1,5,step_size=0.2,default=3), c=slider(1,5,step_size=0.2,default=2), slice = selector(["x","y","z"],default="z"), slice_constant =slider(-5,5,step_size=0.2,default=0), color=selector(["red","green","blue"],label="Color",default="green"), threeD=checkbox(default=false,label='3D view (Red/Cyan glasses)'), ): x1, x2, y1, y2, z1, z2 = -a, a, -b, b, -c, c var("x,y,z,t") surf = x^2/a^2+y^2/b^2+z^2/c^2==1 pretty_print(html(latex(surf))) G = implicit_plot3d(surf, (x,x1,x2), (y,y1,y2), (z,z1,z2), color=color,opacity=0.5) if slice=="x": r = sqrt(a^2/abs(a^2-slice_constant^2)) G += parametric_plot3d([slice_constant,b*cos(t)/r,c*sin(t)/r ],[t,0,2*pi],color='yellow',thickness=10) T = "$$x = k \\\ y = \\frac{b\\cos(t)}{\\sqrt{a^2/(a^2-k^2)}} \\\ z = \\frac{c\\sin(t)}{\\sqrt{a^2/(a^2-k^2)}}$$" pretty_print(html(T)) if slice=="y": r = sqrt(b^2/abs(b^2-slice_constant^2)) G += parametric_plot3d([a*cos(t)/r,slice_constant,c*sin(t)/r ],[t,0,2*pi],color='yellow',thickness=10) T = "$$x = \\frac{a\cos(t)}{\\sqrt{b^2/(b^2-k^2)}} \\\ y = k \\\ z = \\frac{c\sin(t)}{\\sqrt{b^2/(b^2-k^2)}}$$" pretty_print(html(T)) if slice=="z": r = sqrt(c^2/abs(c^2-slice_constant^2)) G += parametric_plot3d([a*cos(t)/r,b*sin(t)/r,slice_constant ],[t,0,2*pi],color='yellow',thickness=10) T = "$$x = \\frac{a\\cos(t)}{\\sqrt{c^2/(c^2-k^2)}} \\\ y = \\frac{b\\sin(t)}{\\sqrt{c^2/(c^2-k^2)}} \\\ z = k$$" pretty_print(html(T)) if threeD: show(G,stereo='redcyan',spin=true,figsize=(8,12),aspect_ratio=(1,1,1)) else: show(G,spin=false,perspective_depth=true,figsize=(8,12),aspect_ratio=(1,1,1))

slice
slice_constant
Color
3D view (Red/Cyan glasses)

## Click to the left again to hide and once more to show the dynamic interactive window

# Hyperboloid of One Sheet @interact def Hyperboloid_One(a=slider(1,5,step_size=0.2,default=3), b=slider(1,5,step_size=0.2,default=3), c=slider(1,5,step_size=0.2,default=2), color=selector(["red","green","blue"],label="Color",default="green"), threeD=checkbox(default=false,label='3D view (Red/Cyan glasses)') ): x1, x2, y1, y2, z1, z2 = -a, a, -b, b, -c, c var("x,y,z") surf = x^2/a^2+y^2/b^2-z^2/c^2==1 G = implicit_plot3d(surf, (x,3*x1,3*x2), (y,3*y1,3*y2), (z,3*z1,3*z2), color=color,opacity=0.7) pretty_print(html(latex(surf))) if threeD: show(G,stereo='redcyan',spin=true,figsize=(8,12),aspect_ratio=(1,1,1)) else: show(G,spin=false,perspective_depth=true,figsize=(8,12),aspect_ratio=(1,1,1))

## Click to the left again to hide and once more to show the dynamic interactive window

# Hyperboloid of Two Sheets @interact def Hyperboloid_Two(a=slider(1,5,step_size=0.2,default=3), b=slider(1,5,step_size=0.2,default=3), c=slider(1,5,step_size=0.2,default=2), color=selector(["red","green","blue"],label="Color",default="green"), threeD=checkbox(default=false,label='3D view (Red/Cyan glasses)') ): x1, x2, y1, y2, z1, z2 = -a, a, -b, b, -c, c var("x,y,z") surf = -x^2/a^2-y^2/b^2+z^2/c^2==1 G = implicit_plot3d(surf, (x,5*x1,5*x2), (y,5*y1,5*y2), (z,5*z1,5*z2), color=color,opacity=0.7) pretty_print(html(latex(surf))) if threeD: show(G,stereo='redcyan',spin=true,figsize=(8,12),aspect_ratio=(1,1,1)) else: show(G,spin=false,perspective_depth=true,figsize=(8,12),aspect_ratio=(1,1,1))

## Click to the left again to hide and once more to show the dynamic interactive window

# Elliptic Cone @interact def Elliptic_Cone(a=slider(1,5,step_size=0.2,default=3), b=slider(1,5,step_size=0.2,default=3), c=slider(1,5,step_size=0.2,default=2), color=selector(["red","green","blue"],label="Color",default="green"), threeD=checkbox(default=false,label='3D view (Red/Cyan glasses)') ): x1, x2, y1, y2, z1, z2 = -a, a, -b, b, -c, c var("x,y,z") surf = x^2/a^2+y^2/b^2-z^2/c^2==0 G = implicit_plot3d(surf, (x,5*x1,5*x2), (y,5*y1,5*y2), (z,5*z1,5*z2), color=color,opacity=0.7) pretty_print(html(latex(surf))) if threeD: show(G,stereo='redcyan',spin=true,figsize=(8,12),aspect_ratio=(1,1,1)) else: show(G,spin=false,perspective_depth=true,figsize=(8,12),aspect_ratio=(1,1,1))

## Click to the left again to hide and once more to show the dynamic interactive window

# Elliptic Paraboloid @interact def Elliptic_Paraboloid(a=slider(1,5,step_size=0.2,default=3), b=slider(1,5,step_size=0.2,default=3), c=slider(1,5,step_size=0.2,default=2), slice = selector(["x","y","z"],default="z"), slice_constant =slider(-5,5,step_size=0.2,default=1), color=selector(["red","green","blue"],label="Color",default="green"), threeD=checkbox(default=false,label='3D view (Red/Cyan glasses)') ): x1, x2, y1, y2, z1, z2 = -a, a, -b, b, -c, c var("x,y,z,t") surf = x^2/a^2+y^2/b^2-z==0 G = implicit_plot3d(surf, (x,5*x1,5*x2), (y,5*y1,5*y2), (z,5*z1,5*z2), color=color,opacity=0.5) pretty_print(html(latex(surf))) if slice=="x": T = "$$x = k \\\ y = t \\\ z = \\frac{k^2}{a^2} + \\frac{t^2}{b^2}$$" G += parametric_plot3d([slice_constant,t,slice_constant^2/a^2+t^2/b^2 ],[t,-10,10],color='yellow',thickness=10) pretty_print(html(T)) if slice=="y": T = "$$x = t \\\ y = k \\\ z = \\frac{t^2}{a^2} + \\frac{k^2}{b^2}$$" G += parametric_plot3d([t,slice_constant,t^2/a^2+slice_constant^2/b^2 ],[t,-10,10],color='yellow',thickness=10) pretty_print(html(T)) if slice=="z": T = "$$x = a\sqrt{k}\cos(t) \\\ y = b\sqrt{k}\sin(t) \\\ z = k$$" r = sqrt(abs(slice_constant)) G += parametric_plot3d([a*cos(t)*r,b*sin(t)*r,slice_constant ],[t,0,2*pi],color='yellow',thickness=10) pretty_print(html(T)) if threeD: show(G,stereo='redcyan',spin=true,figsize=(8,12),aspect_ratio=(1,1,1)) else: show(G,spin=false,perspective_depth=true,figsize=(8,12),aspect_ratio=(1,1,1))

## Click to the left again to hide and once more to show the dynamic interactive window

# Hyperbolic Paraboloid @interact def Hyperbolid_Paraboloid(a=slider(1,5,step_size=0.2,default=3), b=slider(1,5,step_size=0.2,default=3), c=slider(1,5,step_size=0.2,default=2), slice = selector(["x","y","z"],default="z"), slice_constant =slider(-5,5,step_size=0.2,default=1), color=selector(["red","green","blue"],label="Color",default="green"), threeD=checkbox(default=false,label='3D view (Red/Cyan glasses)') ): x1, x2, y1, y2, z1, z2 = -a, a, -b, b, -c, c var("x,y,z,t") surf = -x^2/a^2+y^2/b^2-z==0 G = implicit_plot3d(surf, (x,5*x1,5*x2), (y,5*y1,5*y2), (z,5*z1,5*z2), color=color,opacity=0.5) pretty_print(html(latex(surf))) if slice=="x": T = "$$x = k \\\ y = t \\\ z = -\\frac{k^2}{a^2} + \\frac{t^2}{b^2}$$" G += parametric_plot3d([slice_constant,t,-slice_constant^2/a^2+t^2/b^2 ],[t,-10,10],color='yellow',thickness=10) pretty_print(html(T)) if slice=="y": T = "$$x = t \\\ y = k \\\ z = \\frac{t^2}{a^2} + \\frac{k^2}{b^2}$$" G += parametric_plot3d([t,slice_constant,-t^2/a^2+slice_constant^2/b^2 ],[t,-10,10],color='yellow',thickness=10) pretty_print(html(T)) if slice=="z": r = sqrt(abs(slice_constant)) if slice_constant > 0: G += parametric_plot3d([a*tan(t)*r,b*sec(t)*r,slice_constant ],[t,-1.3,1.3],color='yellow',thickness=10) G += parametric_plot3d([-a*tan(t)*r,-b*sec(t)*r,slice_constant ],[t,-1.3,1.3],color='yellow',thickness=10) T = "$$x = \\pm a\sqrt{k}\\tan(t) \\\ y = \\pm b\\sqrt{k}\sec(t) \\\ z = k$$" if slice_constant < 0: G += parametric_plot3d([a*sec(t)*r,b*tan(t)*r,slice_constant ],[t,-1.3,1.3],color='yellow',thickness=10) G += parametric_plot3d([-a*sec(t)*r,-b*tan(t)*r,slice_constant ],[t,-1.3,1.3],color='yellow',thickness=10) T = "$$x = \\pm a\sqrt{k}\\sec(t) \\\ y = \pm b\\sqrt{k}\tan(t) \\\ z = k$$" pretty_print(html(T)) if threeD: show(G,stereo='redcyan',spin=true,figsize=(8,12),aspect_ratio=(1,1,1)) else: show(G,spin=false,perspective_depth=true,figsize=(8,12),aspect_ratio=(1,1,1))

## Click to the left again to hide and once more to show the dynamic interactive window

# Hyperbolic Paraboloid Shifted from sage.plot.plot3d.plot3d import axes @interact def Hyperbolid_Paraboloid(a=slider(1,5,step_size=0.2,default=3), b=slider(1,5,step_size=0.2,default=3), c=slider(1,5,step_size=0.2,default=2), shift = input_box((-13,-12,9),label='Shift = '), color=selector(["red","green","blue"],label="Color",default="green"), threeD=checkbox(default=false,label='3D view (Red/Cyan glasses)') ): x1, x2, y1, y2, z1, z2 = -a, a, -b, b, -c, c var("x,y,z") surf = -(x-shift[0])^2/a^2+(y-shift[1])^2/b^2-(z-shift[2])==0 G = implicit_plot3d(-x^2/a^2+y^2/b^2-z==0, (x,5*x1,5*x2), (y,5*y1,5*y2), (z,5*z1,5*z2),color='lightgray',opacity=0.3) pretty_print(html(latex(surf))) G += axes(10, color='red',thickness=30) G += implicit_plot3d(-(x-shift[0])^2/a^2+(y-shift[1])^2/b^2-(z-shift[2])==0, (x,5*x1+shift[0],5*x2+shift[0]), (y,5*y1+shift[1],5*y2+shift[1]), (z,5*z1+shift[2],5*z2+shift[2]), color=color) if threeD: show(G,stereo='redcyan',spin=true,figsize=(8,12),aspect_ratio=(1,1,1)) else: show(G,spin=false,perspective_depth=true,figsize=(8,12),aspect_ratio=(1,1,1))

## Click to the left again to hide and once more to show the dynamic interactive window