#!/usr/bin/env python # coding: utf-8 # In[1]: import k3d import k3d.platonic as platonic import math import numpy as np # In[2]: plot = k3d.plot(auto_rendering=False, grid_auto_fit=False, grid_visible=False) plot.display() # In[3]: colors = [0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff] for j in range(5): meshes = [ platonic.Dodecahedron().mesh, platonic.Cube().mesh, platonic.Icosahedron().mesh, platonic.Octahedron().mesh, platonic.Tetrahedron().mesh ] for i, obj in enumerate(meshes): obj.color = colors[i] plot += obj for time in np.linspace(0, 4 * np.pi, 120): k = 0 for j in range(5): for i in range(len(meshes)): rad = math.radians(i / len(meshes) * 360) radius = 3.5 t = k3d.transform() t.translation = [math.sin(rad + time) * radius, math.cos(rad + time) * radius, 2.5*j] t.rotation = [j + time, 0, 0, 1] plot.objects[k].model_matrix = t.model_matrix k += 1 plot.render() # In[4]: plot = k3d.plot() plot.display() colors = [0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff] for j in range(5): meshes = [ platonic.Dodecahedron().mesh, platonic.Cube().mesh, platonic.Icosahedron().mesh, platonic.Octahedron().mesh, platonic.Tetrahedron().mesh ] for i, obj in enumerate(meshes): rad = math.radians(i / len(meshes) * 360) radius = 3.5 model_matrix = {} for time in np.linspace(0, 2 * np.pi, 60): t = k3d.transform() t.translation = [math.sin(rad + time) * radius, math.cos(rad + time) * radius, 2.5*j] t.rotation = [time - j, 0, 0, 1] model_matrix[str(time)] = t.model_matrix obj.model_matrix = model_matrix obj.color = colors[i] plot += obj # In[5]: plot.grid_auto_fit = False plot.camera_auto_fit = False # In[6]: plot.start_auto_play() # In[ ]: plot.stop_auto_play() # In[ ]: