Created
December 14, 2018 09:56
-
-
Save gwater/a71f37c3605474630da9bffd4e97bd77 to your computer and use it in GitHub Desktop.
Plots.jl wireframe animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
], | |
"source": [ | |
"using StaticArrays\n", | |
"using LinearAlgebra\n", | |
"using Plots\n", | |
"\n", | |
"function r_top(p)\n", | |
" pr = norm(p)\n", | |
" pϕ = atan(p[2], p[1])\n", | |
" ampxy = sqrt(2pr - pr^2)\n", | |
" return SVector(ampxy * cos(pϕ), 0.5ampxy * sin(pϕ), 1 - pr)\n", | |
"end\n", | |
"\n", | |
"rot_matrix_z(β) = SMatrix{3,3}(\n", | |
" cos(β), sin(β), 0,\n", | |
" -sin(β), cos(β), 0,\n", | |
" 0 , 0 , 1)\n", | |
"rot_matrix_x(β) = SMatrix{3,3}(\n", | |
" 1, 0, 0,\n", | |
" 0, cos(β), sin(β),\n", | |
" 0, -sin(β), cos(β))\n", | |
"\n", | |
"@gif for β in 0:6e-2:2pi\n", | |
" rot_mat = rot_matrix_x(atan(1 / sqrt(2))) * rot_matrix_z(β)\n", | |
" scatter(zeros(1), zeros(1))\n", | |
" for pϕ in 0:pi / 7:2pi\n", | |
" ps_smooth = map(pr -> SVector(pr * sin(pϕ), pr * cos(pϕ)), 0:1e-3:1)\n", | |
" plot!(map(r -> (rot_mat * r)[1], r_top.(ps_smooth)),\n", | |
" map(r -> (rot_mat * r)[3], r_top.(ps_smooth)),\n", | |
" color = :black, legend = false)\n", | |
" end\n", | |
" for pr in 0:1 / 7:1\n", | |
" ps_smooth = map(pϕ -> pr * SVector(cos(pϕ), sin(pϕ)), 0:1e-3:2pi)\n", | |
" plot!(map(r -> (rot_mat * r)[1], r_top.(ps_smooth)),\n", | |
" map(r -> (rot_mat * r)[3], r_top.(ps_smooth)),\n", | |
" color = :black, legend = false)\n", | |
" end\n", | |
" ylims!(-1, 1.5)\n", | |
" xlims!(-1.5, 1.5)\n", | |
"end" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Julia 1.0.2", | |
"language": "julia", | |
"name": "julia-1.0" | |
}, | |
"language_info": { | |
"file_extension": ".jl", | |
"mimetype": "application/julia", | |
"name": "julia", | |
"version": "1.0.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment