Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in display when using animation_control #255

Open
fran6w opened this issue Jun 3, 2019 · 0 comments
Open

Error in display when using animation_control #255

fran6w opened this issue Jun 3, 2019 · 0 comments

Comments

@fran6w
Copy link

fran6w commented Jun 3, 2019

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])

spinning_cube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant