Created
January 31, 2024 12:30
-
-
Save empet/8d30ea58a700b3cfdc7002b134cee7ec to your computer and use it in GitHub Desktop.
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": "markdown", | |
"id": "1dfa1a6f", | |
"metadata": {}, | |
"source": [ | |
"## <center> Conformal mapping of a planar tilling onto torus </center>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "2abf3d01", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"using PlotlyJS, Images" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "fa34e34e", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"function conformal_torus(sizerect::Tuple{Int, Int})\n", | |
" #conformal torus parameterization http://archive.bridgesmathart.org/2011/bridges2011-593.pdf\n", | |
" r, c = sizerect\n", | |
" a = c/r\n", | |
" ul = collect(range(-a*pi, a*pi, c))\n", | |
" vl = collect(range(-pi, pi, r))\n", | |
" u = ones(size(vl))*ul'\n", | |
" v = vl*ones(size(ul))'\n", | |
" tp = @. sqrt(a^2+1)-cos(v)\n", | |
" x = @. a*cos(u/a)/tp\n", | |
" y = @. a*sin(u/a)/tp\n", | |
" z = @. sin(v)/tp;\n", | |
" return x, y, z \n", | |
"end" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "2b3c9101", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"img=load(\"Patterns/tilling.jpg\")\n", | |
"r, c=size(img)\n", | |
"rgbm = permutedims(channelview(img), (2,3,1))\n", | |
"surfcolor=rgbm[:, :, 1];" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "6e6e1d07", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"fig1=Plot(heatmap(z=surfcolor, colorscale=colors.deep, showscale=false),\n", | |
" Layout(width=div(c,2), height=div(r, 2), xaxis_visible=false, yaxis_visible=false,\n", | |
" margin=attr(t=2, r=2, b=2, l=2)))\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "b566b550", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"x, y, z = conformal_torus(size(img));\n", | |
"\n", | |
"fig2 = Plot(surface(x=x, y=y, z=z, colorscale=colors.deep, surfacecolor=surfcolor, showscale=false), \n", | |
" Layout(width=700, height=450, margin=attr(t=2, r=2, b=2, l=2),\n", | |
" scene=attr(xaxis_visible=false, yaxis_visible=false, zaxis_visible=false)))" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "765e345f", | |
"metadata": {}, | |
"source": [ | |
"![pl tilling](https://github.com/empet/Datasets/blob/master/Images/tesselationtoctorus.png?raw=true)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "e5719840", | |
"metadata": {}, | |
"source": [ | |
"![conformal torus](https://github.com/empet/Datasets/blob/master/Images/conformal_torus.png?raw=true)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "7bc6f159", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"@webio": { | |
"lastCommId": null, | |
"lastKernelId": null | |
}, | |
"kernelspec": { | |
"display_name": "Julia 1.9.0", | |
"language": "julia", | |
"name": "julia-1.9" | |
}, | |
"language_info": { | |
"file_extension": ".jl", | |
"mimetype": "application/julia", | |
"name": "julia", | |
"version": "1.9.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment