You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The display of a spinning cube shows the bottom and top vertices rotating but they should not
from numpy import array, pi, cos, sin, sqrt
def spinning_cube(n=24):
assert(n % 6 == 0)
sqrt3 = sqrt(3)
r = sqrt(2/3)
x = array([[0, 0, [rcos(a2pi/3+t2pi/n) for a in range(3)], [rcos(a2pi/3+pi/3+t2pi/n) for a in range(3)]] for t in range(n)])
y = array([[0, 0, [rsin(a2pi/3+t2pi/n) for a in range(3)], [rsin(a2pi/3+pi/3+t2pi/n) for a in range(3)]] for t in range(n)])
z = array([0, sqrt3, sqrt3/3, sqrt3/3, sqrt3/3, sqrt32/3, sqrt32/3, sqrt3*2/3])
triangles = [[0, 2, 3], [0, 3, 4], [0, 2, 4],
[1, 5, 6], [1, 6, 7], [1, 5, 7],
[2, 3, 5], [3, 4, 6], [2, 4, 7],
[5, 6, 3], [6, 7, 4], [5, 7, 2]]
return x, y, z, triangles
import ipyvolume as ipv
ipv.figure()
ipv.style.use('minimal')
x, y, z, triangles = spinning_cube(6)
s = ipv.plot_trisurf(x, z, y, triangles=triangles)
ipv.animation_control(s, interval=100)
ipv.show()
ipv.movie('spinning_cube.gif', fps=20, frames=20*4,)
data used
vertex 0 is (0, 0, 0) and vertex 1 is (0, 0, sqrt(3)/2) in all frames
The display of a spinning cube shows the bottom and top vertices rotating but they should not
from numpy import array, pi, cos, sin, sqrt
def spinning_cube(n=24):
assert(n % 6 == 0)
sqrt3 = sqrt(3)
r = sqrt(2/3)
x = array([[0, 0, [rcos(a2pi/3+t2pi/n) for a in range(3)], [rcos(a2pi/3+pi/3+t2pi/n) for a in range(3)]] for t in range(n)])
y = array([[0, 0, [rsin(a2pi/3+t2pi/n) for a in range(3)], [rsin(a2pi/3+pi/3+t2pi/n) for a in range(3)]] for t in range(n)])
z = array([0, sqrt3, sqrt3/3, sqrt3/3, sqrt3/3, sqrt32/3, sqrt32/3, sqrt3*2/3])
triangles = [[0, 2, 3], [0, 3, 4], [0, 2, 4],
[1, 5, 6], [1, 6, 7], [1, 5, 7],
[2, 3, 5], [3, 4, 6], [2, 4, 7],
[5, 6, 3], [6, 7, 4], [5, 7, 2]]
return x, y, z, triangles
import ipyvolume as ipv
ipv.figure()
ipv.style.use('minimal')
x, y, z, triangles = spinning_cube(6)
s = ipv.plot_trisurf(x, z, y, triangles=triangles)
ipv.animation_control(s, interval=100)
ipv.show()
ipv.movie('spinning_cube.gif', fps=20, frames=20*4,)
data used
vertex 0 is (0, 0, 0) and vertex 1 is (0, 0, sqrt(3)/2) in all frames
therefore they should not display rotating
x = array([[ 0. , 0. , 0.81649658, -0.40824829, -0.40824829,
0.40824829, -0.81649658, 0.40824829],
[ 0. , 0. , 0.40824829, -0.81649658, 0.40824829,
-0.40824829, -0.40824829, 0.81649658],
[ 0. , 0. , -0.40824829, -0.40824829, 0.81649658,
-0.81649658, 0.40824829, 0.40824829],
[ 0. , 0. , -0.81649658, 0.40824829, 0.40824829,
-0.40824829, 0.81649658, -0.40824829],
[ 0. , 0. , -0.40824829, 0.81649658, -0.40824829,
0.40824829, 0.40824829, -0.81649658],
[ 0. , 0. , 0.40824829, 0.40824829, -0.81649658,
0.81649658, -0.40824829, -0.40824829]])
y = array([[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
7.07106781e-01, -7.07106781e-01, 7.07106781e-01,
9.99919924e-17, -7.07106781e-01],
[ 0.00000000e+00, 0.00000000e+00, 7.07106781e-01,
9.99919924e-17, -7.07106781e-01, 7.07106781e-01,
-7.07106781e-01, -9.25178628e-16],
[ 0.00000000e+00, 0.00000000e+00, 7.07106781e-01,
-7.07106781e-01, -1.99983985e-16, 9.99919924e-17,
-7.07106781e-01, 7.07106781e-01],
[ 0.00000000e+00, 0.00000000e+00, 9.99919924e-17,
-7.07106781e-01, 7.07106781e-01, -7.07106781e-01,
-1.99983985e-16, 7.07106781e-01],
[ 0.00000000e+00, 0.00000000e+00, -7.07106781e-01,
-1.99983985e-16, 7.07106781e-01, -7.07106781e-01,
7.07106781e-01, 2.99975977e-16],
[ 0.00000000e+00, 0.00000000e+00, -7.07106781e-01,
7.07106781e-01, 2.99975977e-16, -1.99983985e-16,
7.07106781e-01, -7.07106781e-01]])
z = array([0. , 1.73205081, 0.57735027, 0.57735027, 0.57735027,
1.15470054, 1.15470054, 1.15470054])
The text was updated successfully, but these errors were encountered: