Skip to content

Instantly share code, notes, and snippets.

@brv00
Last active March 15, 2018 11:51
Show Gist options
  • Save brv00/88cebea9e3b92f81b2fd5d90aa0150b5 to your computer and use it in GitHub Desktop.
Save brv00/88cebea9e3b92f81b2fd5d90aa0150b5 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"next_pos (generic function with 1 method)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function next_pos(v)\n",
" f₁(v) = [1/2 -1/2; 1/2 1/2]*v + [1/2, -1/2]\n",
" f₂(v) = [0 -1; 1 0]*f₁(v)\n",
" \n",
" rand([f₁ f₂])(v)\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mSaved animation to https://user-images.githubusercontent.com/35671444/37461322-4fbbf24a-2891-11e8-87bf-c384e061bdd1.gif\n",
"\u001b[39m"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"1943.213919 seconds (1.28 G allocations: 47.840 GiB, 1.45% gc time)\n"
]
},
{
"data": {
"text/html": [
"<img src=\"https://user-images.githubusercontent.com/35671444/37461322-4fbbf24a-2891-11e8-87bf-c384e061bdd1.gif\" />"
],
"text/plain": [
"Plots.AnimatedGif(\"https://user-images.githubusercontent.com/35671444/37461322-4fbbf24a-2891-11e8-87bf-c384e061bdd1.gif\")"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"using Plots\n",
"gr(legend=false, color=:blue)\n",
"ENV[\"PLOTS_TEST\"]=\"true\"\n",
"\n",
"function f() \n",
" v = [0,0]\n",
" plot([v[1],v[1]+0.003], [v[2],v[2]+0.001], size=(500,500), xlims=(-1,2), ylims=(-1,2))\n",
" @gif for i in 1:100000\n",
" v = next_pos(v)\n",
" plot!([v[1],v[1]+0.003], [v[2],v[2]+0.003])\n",
" end every 200\n",
"end\n",
"@time f()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 0.6.2",
"language": "julia",
"name": "julia-0.6"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "0.6.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment