A coffee cup and a doughnut
Just for fun!
GGB script
#-------------------------
# Stuff for animation
# Based upon Bernat's work
#-------------------------
top = Slider(0, 3, 1, 1, 200, false, true, false, false)
SetValue(top, 2)
SetVisibleInView(top, 1, false)
k = Slider(0, top, 0.01, 1, 200, false, true, false, false)
SetCaption(k, "Change")
sl = Sequence(Max(0, Min(1, k - s)), s, 0, top-1)
mb = 1
mc = 2
#-------------------------
# Auxiliar base for cylinder
#-------------------------
A = (-2.5, 0, 0)
B = (-3.5, 0, -0.3) * Element(sl, mc) + (1 - Element(sl, mc)) * (-5, 0, -4)
C = (x(B) - x(B) * 0.06, y(B), z(B)) * Element(sl, mc) + (1 - Element(sl, mc)) * (x(B)- x(B) * 0.06, y(B), z(B))
#-------------------------
# Cup exterior
#-------------------------
r1 = 1 * Element(sl, mc) + (1 - Element(sl, mc)) * 2.5
max = 0.3 * Element(sl, mc) + (1 - Element(sl, mc)) * 3
min = -0.3 * Element(sl, mc) + (1 - Element(sl, mc)) * (-4)
gx(x, y) = r1 cos(x) - 2.5
gy(x, y) = r1 sin(x)
gz(x, y) = y
cylOut = Surface(gx(u, v), gy(u, v), gz(u,v), u, 0, 2pi, v, min, max)
#-------------------------
# Base
#-------------------------
BT = (x(B), y(B), z(B) + (max - min))
CT = (x(C), y(C), z(C) + (max - min))
f = PerpendicularLine(A, xOyPlane)
c = Circle(f, B)
#-------------------------
# First top cover
#-------------------------
AR = (-0.3, 0, 3)
BR = (0, 0, 3)
ARB = AR * Element(sl, mb) + (1 - Element(sl, mb)) * (-0.3, 0, -3.8)
d = Circle(f, ARB)
#-------------------------
# Cup interior
#-------------------------
r2 = (r1 - r1 * 0.1) * Element(sl, mc) + (1 - Element(sl, mc)) * (r1 - r1 * 0.1)
hx(x, y) = r2 cos(x) - 2.5
hy(x, y) = r2 sin(x)
hz(x, y) = y
cylIn = Surface(hx(u, v), hy(u, v), hz(u,v), u, 0, 2pi, v, min, max)
#-------------------------
# Second top cover
#-------------------------
u = Vector(CT, BT)
b = Curve(x(CT) + t x(u), y(CT) + t y(u), z(CT) + t z(u), t, 0, 1)
topCup = Surface(b, 2π, f)
cover = Circle(f, CT)
#-------------------------
# Finally the torus
#-------------------------
at = 1.5 * Element(sl, mc) + (1 - Element(sl, mc)) * 0.4
ct = 3 * Element(sl, mc) + (1 - Element(sl, mc)) * 2
fx(x, y) = (ct+ at * cos(y)) * cos(x)
fy(x, y) = -at * sin(y)
fz(x, y) = (ct+ at * cos(y)) * sin(x)
maxT = If(k<1, pi/2 + 0.05, pi)
#pi * Element(sl, 2) + (1 - Element(sl, 2)) * (pi/2 + 0.05)
minT = If(k<1, -pi/2 - 0.05, -pi)
#-pi * Element(sl, 2) + (1 - Element(sl, 2)) * (-pi/2 - 0.05)
t = Surface(fx(u, v), fy(u, v), fz(u,v), u, minT, maxT, v, -pi, pi+0.5)
#-------------------------
# Some extra settings
#-------------------------
SetVisibleInView(A, -1, false)
SetVisibleInView(B, -1, false)
SetVisibleInView(C, -1, false)
SetVisibleInView(AR, -1, false)
SetVisibleInView(ARB, -1, false)
SetVisibleInView(BR, -1, false)
SetVisibleInView(BT, -1, false)
SetVisibleInView(CT, -1, false)
SetVisibleInView(gx, -1, false)
SetVisibleInView(gy, -1, false)
SetVisibleInView(gz, -1, false)
SetVisibleInView(hx, -1, false)
SetVisibleInView(hy, -1, false)
SetVisibleInView(hz, -1, false)
SetVisibleInView(fx, -1, false)
SetVisibleInView(fy, -1, false)
SetVisibleInView(fz, -1, false)
SetVisibleInView(u, -1, false)
SetVisibleInView(b, -1, false)
SetConditionToShowObject(cover, k > 1)
SetConditionToShowObject(d, k <= 1)
SetLineThickness(c, 0.05)
SetLineThickness(cover, 0.05)
SetLineThickness(d, 0.05)