Spinning cube - Belt Trick

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

Information: Spinning cube - Belt Trick