{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from k3d import K3D\n", "from math import sin, cos, pi\n", "\n", "width = height = 20\n", "view_matrix = (\n", " 7.0, 5.0, -5.0, 0.0,\n", " 0.0, 7.0, 7.0, 5.0,\n", " 7.0, -5.0, 5.0, 0.0,\n", " 0.0, 0.0, 0.0, 1.0\n", ")\n", "\n", "def f(x, y):\n", " return sin(float(x) / width * pi * 2.0), cos(float(y) / height * pi * 2.0)\n", "\n", "colors = (0xFF0000, 0x00FF00) * width * height\n", "vectors = [[f(x, y) for y in range(height)] for x in range(width)]\n", "\n", "plot = K3D()\n", "plot += K3D.vectors_fields(vectors, colors, view_matrix=view_matrix)\n", "plot.display()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 0 }