Datasets:
Formats:
json
Languages:
English
Size:
< 1K
Tags:
Synthetic
scene-flow
geometric-computing
computational-geometry
unbalanced-optimal-transport
numerical-analysis
Download code/figure.py from PureOne/Nyeolixa: direct link, hf CLI and curl.
- Browser
- Download file 1.88 kB
-
https://huggingface.co/datasets/PureOne/Nyeolixa/resolve/main/code/figure.py
- Command line
-
hf download hf://datasets/PureOne/Nyeolixa/code/figure.py
-
curl -L -o figure.py https://huggingface.co/datasets/PureOne/Nyeolixa/resolve/main/code/figure.py
1.88 kB
| """Plot level curves of the explicit polynomial circulation on x+y+z=1/2.""" | |
| from pathlib import Path | |
| import math | |
| import matplotlib | |
| matplotlib.use("Agg") | |
| import matplotlib.pyplot as plt | |
| import matplotlib.tri as tri | |
| import numpy as np | |
| N = 100 | |
| bary = np.array([(i/N, j/N, (N-i-j)/N) | |
| for i in range(N+1) for j in range(N-i+1)]) | |
| corners = np.array([[0.,0.], [1.,0.], [0.5,math.sqrt(3)/2]]) | |
| xy = bary @ corners | |
| mesh = tri.Triangulation(xy[:,0],xy[:,1]) | |
| fig, axes = plt.subplots(1,2,figsize=(7.0,2.42)) | |
| for ax, title in zip(axes,["Affine flux", "Continuum cell"]): | |
| ax.fill(*corners.T,facecolor="#f7f6fa",edgecolor="#655072",linewidth=1.1) | |
| ax.set_aspect("equal") | |
| ax.set_xlim(-.06,1.06); ax.set_ylim(-.05,.96) | |
| ax.set_title(title,fontsize=12,color="#332c3f",pad=2) | |
| ax.axis("off") | |
| axes[0].text(.5,.29,"$m=0$",ha="center",va="center",fontsize=15,color="#625a69") | |
| axis=axes[1] | |
| levels=[.005,.012,.021,.029,.0348] | |
| axis.tricontour(mesh,np.prod(bary,axis=1),levels=levels, | |
| colors=["#705280","#705280","#5a477a","#476074","#32777c"],linewidths=1.25) | |
| # The plane and xyz are both first integrals. Use exact field tangents. | |
| for level in [levels[0],levels[2],levels[4]]: | |
| roots=np.roots([2.,-1.,0.,level]) | |
| t=next(v.real for v in roots if abs(v.imag)<1e-10 and 0<v.real<1/3) | |
| u=np.array([t,t,1-2*t]) | |
| f=u*np.array([u[2]-u[1],u[0]-u[2],u[1]-u[0]]) | |
| pt=u@corners; direction=f@corners; direction=direction/np.linalg.norm(direction) | |
| axis.annotate("",xy=pt+.017*direction,xytext=pt-.017*direction, | |
| arrowprops={"arrowstyle":"-|>","color":"#523f70","mutation_scale":10,"lw":1.1, | |
| "shrinkA":0,"shrinkB":0}) | |
| fig.subplots_adjust(left=.035,right=.965,bottom=.02,top=.88,wspace=.05) | |
| fig.savefig(Path(__file__).with_name("circulation.pdf"),bbox_inches="tight",pad_inches=.025) | |
| plt.close(fig) | |