Spinning cube - Belt Trick
GIF
Animation inspired by
Jason Hise: Belt Trick and Pixelated_Donut
Also check: The Strange Numbers That Birthed Modern Algebra
Warning: The interactive demo is laggy. Download for better performance.
Interactive Demo
Script
# A spinning cube with attached ribbons returns
# to its original state only after two full turns,
# rather than one turn. Four-dimensional numbers
# called quaternions behave similarly, as do matter
# particles such as electrons and quarks.
# https://www.quantamagazine.org/the-strange-numbers-that-birthed-modern-algebra-20180906/
speed = 1
α = Slider(0°, 360°, 1°, speed, 200)
C = (cos(α), sin(α), 0)
# Auxiliary functions
#T(x, y, z) = pi / ( 1 + exp(sqrt( x^2+y^2+z^2) - 9 ) )
CrossX(x, y, z) = y * z(C) - z * y(C)
CrossY(x, y, z) = z * x(C) - x * z(C)
CrossZ(x, y, z) = x * y(C) - y * x(C)
Dot(x, y, z) = x * x(C) + y * y(C) + z * z(C)
KX(x, y, z) = ( x * x(C) + y * y(C) + z * z(C) ) * x(C)
KY(x, y, z) = ( x * x(C) + y * y(C) + z * z(C) ) * y(C)
KZ(x, y, z) = ( x * x(C) + y * y(C) + z * z(C) ) * z(C)
PMinusKX(x, y, z) = ( x - KX(x, y, z) ) * cos( pi / ( 1 + exp(sqrt( x^2+y^2+z^2) - 9 ) ) )
PMinusKY(x, y, z) = ( y - KY(x, y, z) ) * cos( pi / ( 1 + exp(sqrt( x^2+y^2+z^2) - 9 ) ) )
PMinusKZ(x, y, z) = ( z - KZ(x, y, z) ) * cos( pi / ( 1 + exp(sqrt( x^2+y^2+z^2) - 9 ) ) )
PCrossCX(x, y, z) = CrossX(x, y, z) * sin( pi / ( 1 + exp(sqrt( x^2+y^2+z^2) - 9 ) ) )
PCrossCY(x, y, z) = CrossY(x, y, z) * sin( pi / ( 1 + exp(sqrt( x^2+y^2+z^2) - 9 ) ) )
PCrossCZ(x, y, z) = CrossZ(x, y, z) * sin( pi / ( 1 + exp(sqrt( x^2+y^2+z^2) - 9 ) ) )
RX(x, y, z) = KX(x, y, z) + PMinusKX(x, y, z) - PCrossCX(x, y, z)
RY(x, y, z) = KY(x, y, z) + PMinusKY(x, y, z) - PCrossCY(x, y, z)
RZ(x, y, z) = KZ(x, y, z) + PMinusKZ(x, y, z) - PCrossCZ(x, y, z)
# Curves
c1 = Curve( RX(cos(2pi * t)+20*tanh(9*cos(2pi * t)), sin(2pi * t), 0), RY(cos(2pi * t)+20*tanh(9*cos(2pi * t)), sin(2pi * t), 0), RZ(cos(2pi * t)+20*tanh(9*cos(2pi * t)), sin(2pi * t), 0), t, 0, 1)
c2 = Curve( RX(0, cos(2pi * t)+20*tanh(9*cos(2pi * t)), sin(2pi * t)), RY(0, cos(2pi * t)+20*tanh(9*cos(2pi * t)), sin(2pi * t)), RZ(0, cos(2pi * t)+20*tanh(9*cos(2pi * t)), sin(2pi * t)), t, 0, 1)
c3 = Curve( RX(sin(2pi * t), 0, cos(2pi * t)+20*tanh(9*cos(2pi * t))), RY(sin(2pi * t), 0, cos(2pi * t)+20*tanh(9*cos(2pi * t))), RZ(sin(2pi * t), 0, cos(2pi * t)+20*tanh(9*cos(2pi * t))), t, 0, 1)
# Cube
s = 2.5
A1 = (s, s, -s)
A2 = (-s, s, -s)
A3 = (-s, -s, -s)
cube = Rotate(Cube(A1, A2, A3), 2*α, zAxis)