Water Displacement
Author: John Golden

Update of this sketch https://www.geogebra.org/m/AYYR3kAp
which was inspired by a Jennifer Silverman activity, http://www.jensilvermath.com/lessons/algebra21/the-thirsty-crow/

Challenge from Jed Butler: make it animated!

Drop

starting

current

Overflow!

Glass height:

Glass radius:

Marble radius:

setup

Reset

h_3 = 3 (slider from 1 to 4, step 1)
SR = 10 (slider from 1 to 20, step 1)
WH = 60
GR: ((SR^(3 / 2) * (1 / 3)^(1 / 2)) * (4 / h_3)^(1 / 2))
NS: floor(GR / SR)
N = 0
rows = Max(1, ceil(N / NS))
d: (WH / (((rows * 2) * SR)) * 10)
SV: ((π * 4 / 3) * SR^(3))
w = 60 (slider from ceil((4 * SR)) to GH, step 1)
A: (0, 0)
C: (GR, (-0.3 * GR))
B: ((2 * GR), 0)
I = Midpoint(A, B)
GH: 100
GV: ((π * GR^(2)) * GH)
D: B + (0, GH)
E: A + (0, GH)
F: E + (GR - SR, (0.35 * GR))
G: F + ((2 * SR), 0)
c: (x - x(I))^(2) / GR^(2) + (y - y(I))^(2) / y(C)^(2) = 1
c' = Translate(c, Vector[A, E])
WD: SV / ((π * GR^(2)))
f(x) = (y(C) * sqrt(1 - (x - x(I))^(2) / GR^(2)))
g(x) = ((-y(C)) * sqrt(1 - (x - x(I))^(2) / GR^(2))) + WH
h(x) = If[x < 1, 1, 0]
i = Segment(A, E)
list1 = Join(Sequence[Sequence[(GR - (NS * SR), 0) + (i * ((2 * SR), 0)) + (j * (0, d)), i, 0, NS - 1], j, 0, rows])
j = Segment(B, D)
t = 0 (slider from 0 to 1, step 0.01)
a(x, y) = f(x) < y < WH ∧ 0.01 < x < (2 * GR) - 0.01
b(x, y) = WH < y < g(x)
s = 0 (slider from 0 to 1, step 0.05)
c'_1 = Translate(c, (0, WH))
H: (x(B), w)
J: (x(B), WH)
sS: GH / SR
over: WH > GH
oldWH = 100
InputBox1 = Textfield(GH)
InputBox2 = Textfield(GR)
InputBox3 = Textfield(SR)
e = false
WH_1: w + (N * WD)
drop = false
F': F - (t * (0, GH + (0.55 * GR)))
K: (0, w)
L: ((GR * 2), GH)
M: (GR, 0)
d_1 = 2 (slider from -5 to 5, step 0.1)
c_2: (x - x(I))^(2) / ((d_1 * GR))^(2) + (y - y(I))^(2) / ((d_1 * y(C)))^(2) = 1
list2 = Sequence(Translate[pic2, Vector[F, A + Element[list1, i]]], i, 1, N - 1)
pic2' = Translate(pic2, Vector[F, F'])
list3 = Sequence(Segment[(0.25, i), (1, i)], i, 5, 100, 5)
list4 = Sequence(Text[i, (-10, i - 2)], i, 10, 100, 10)
text2: "" + N + " marble" + (If[N ≟ 1, "", "s"]) + "
Water level: " + WH + " ml"
O: (-1, 100.2)
P: (0.5, 100)
Q: (-1, 118)
R: (2, 118)
poly1, o, p, r, q = Polygon(O, P, R, Q)
S: (2, 150)
T: (-10, 150)
U: (-10, 117)
poly2, r_1, s_1, t_1, u = Polygon(R, S, T, U)