Interactive Quartic Surfaces

4279 days ago by medlock

# Function that returns "+" if x >= 0, and "-" if x < 0. # This is just to make things pretty def sign(x): if x >= 0.0: return "+" else: return "-" # Function that returns "" if x >= 0, and "-" if x < 0. def frontSign(x): if x < 0.0: return "-" else: return "" 
       
@interact def _(a = (1, (-5, 5)), b = (1, (-5, 5))): html("<div class='math'>z = %s x^2 / %f %s y^2 / %f</div>" % (frontSign(a), abs(a), sign(b), abs(b))) var('u v') P = plot3d((u^2 / a + v^2 / b), (u, -1, 1), (v, -1, 1), aspect_ratio = [1, 1, 1]) show(P) 
       

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

@interact def _(a = (1, (0, 5)), b = (1, (-5, 5)), c = (1, (-5, 5))): html("<div class='math'>x^2 / %f %s y^2 / %f %s z^2 / %f = 1</div>" % (abs(a), sign(b), abs(b), sign(c), abs(c))) var('u v') if b >= 0 and c >= 0: x = sqrt(a) * cos(u) * sin(v) y = sqrt(b) * sin(u) * sin(v) z = sqrt(c) * cos(v) umin = pi / 2 umax = 3 * pi / 2 vmin = 0 vmax = pi elif b >= 0 and c < 0: x = sqrt(a) * cos(u) * cosh(v) y = sqrt(b) * sin(u) * cosh(v) z = sqrt(-c) * sinh(v) umin = pi / 2 umax = 3 * pi / 2 vmin = -1 vmax = 1 elif b < 0 and c >= 0: x = sqrt(a) * cos(u) * cosh(v) y = sqrt(-b) * sinh(v) z = sqrt(c) * sin(u) * cosh(v) umin = pi / 2 umax = 3 * pi / 2 vmin = -1 vmax = 1 else: x = sqrt(a) * cosh(v) y = sqrt(-b) * cos(u) * sinh(v) z = sqrt(-c) * sin(u) * sinh(v) umin = 0 umax = 2 * pi vmin = -1 vmax = 1 P = parametric_plot3d([[-x, y, z], [x, y, z]], (u, umin, umax), (v, vmin, vmax), aspect_ratio = [1, 1, 1]) show(P) 
       

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

@interact def _(d = (1, (-1, 1))): html("<div class='math'>%s x^2 %s y^2 %s z^2 = %f</div>" % (frontSign(d), sign(d), sign(-d), abs(d))) var('u v') if d >= 0: x = sqrt(d) * cos(u) * cosh(v) y = sqrt(d) * sin(u) * cosh(v) z = sqrt(d) * sinh(v) umin = 0 umax = 2 * pi vmin = 0 vmax = arcsinh(2 / sqrt(d)) else: x = sqrt(-d) * cos(u) * sinh(v) y = sqrt(-d) * sin(u) * sinh(v) z = sqrt(-d) * cosh(v) umin = 0 umax = 2 * pi vmin = 0 vmax = arccosh(2 / sqrt(-d)) P = parametric_plot3d([[x, y, z], [x, y, -z]], (u, umin, umax), (v, vmin, vmax), aspect_ratio = [1, 1, 1]) show(P) 
       

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