{ "cells": [ { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "import k3d\n", "import k3d.platonic as platonic\n", "import math\n", "import numpy as np\n", "\n", "def test(plot):\n", " colors = [0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff]\n", "\n", " for j in range(5):\n", " meshes = [\n", " platonic.Dodecahedron().mesh,\n", " platonic.Cube().mesh,\n", " platonic.Icosahedron().mesh,\n", " platonic.Octahedron().mesh,\n", " platonic.Tetrahedron().mesh\n", " ]\n", "\n", " for i, obj in enumerate(meshes):\n", " rad = math.radians(i / len(meshes) * 360)\n", " radius = 3.5\n", " obj.transform.translation = [math.sin(rad) * radius, math.cos(rad) * radius, 2*j]\n", " obj.color = colors[i]\n", " plot += obj\n", "\n", " plot.render()" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "394df30421384e749cfb2765e1f9470f", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Output()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plot = k3d.plot()\n", "plot.display()" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "plot.auto_rendering = True" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "test(plot)" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "while plot.objects:\n", " plot -= plot.objects[-1]\n", "\n", "plot.render()" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "plot.auto_rendering = False" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "while len(plot.objects)>2:\n", " plot -= plot.objects[-1]" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "plot.render()" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [], "source": [ "import numpy as np " ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [], "source": [ "for i in range(10):\n", " plot += k3d.points(np.random.randn(1,3))#,color=0xff0000)\n", " plot.camera = [-0.9639876204909027,\n", " -23.61169267956684,\n", " i,\n", " 0,\n", " 0.334220290184021,\n", " 4,\n", " 0.007512009764659415,\n", " 0.3054834418666324,\n", " 0.9521677564665881]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.render()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for i in range(100):\n", " plot.camera = [940.698323963372,\n", " -1632.233209973555,\n", " i*10,\n", " 4.949999809265137,\n", " -490.04998779296875,\n", " 49.005001068115234,\n", " 0.008397615690103343,\n", " 0.012813759314055312,\n", " 0.9998826369244359]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" }, "nbTranslate": { "displayLangs": [ "en", "pl" ], "hotkey": "alt-t", "langInMainMenu": true, "sourceLang": "pl", "targetLang": "en", "useGoogleTranslate": true } }, "nbformat": 4, "nbformat_minor": 2 }