Skip to content

Commit

Permalink
fix hopf fibration pov file missing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
neozhaoliang committed Feb 3, 2024
1 parent 9379bc0 commit ebed3f4
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# A Tour in the Wonderland of Math with Python

[![CI](https://github.com/neozhaoliang/pywonderland/actions/workflows/test.yaml/badge.svg)](https://github.com/neozhaoliang/pywonderland/actions/workflows/test.yaml)
[![CI](https://github.com/neozhaoliang/pywonderland/actions/workflows/test.yaml/badge.svg)](https://github.com/neozhaoliang/pywonderland/actions/workflows/test.yaml)
2 changes: 1 addition & 1 deletion src/cftp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
1. [Blog post](https://possiblywrong.wordpress.com/2018/02/23/coupling-from-the-past/) by Possibly Wrong.
2. Wilson's paper "Mixing times of lozenge tiling and card shuffling Markv chains".
3. Häggström's book "Markov chains and algorithmic applications"
4. Book by David Asher Levin, Elizabeth Lee Wilmer, and Yuval Peres "Markov chains and mixing times".
4. "Markov chains and mixing times". Book by David Asher Levin, Elizabeth Lee Wilmer, and Yuval Peres.
5. [Markov Chain Algorithms for Planar Lattice Structures](https://www.researchgate.net/publication/2455641_Markov_Chain_Algorithms_for_Planar_Lattice_Structures).
4 changes: 2 additions & 2 deletions src/misc/Hopf_Fibration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To visualize the Hopf fibration we want to choose some points on the 2-sphere $S^2$, draw their fibers and and see what they look like. Since these fibers lie in the 4d space we cannot see them directly, but if we project them to 3d space using the [stereographic projection](https://en.wikipedia.org/wiki/Stereographic_projection) then some remarkable structure appears. The fibers are projected to circles in 3d space (one of which in a line, comes from the fiber through infinity), any two such circles are linked with each other and the line passes through all circles. The 3d space is filled with nested tori made of linking Villarceau circles, each tori is the preimage of a circle of latitude of the 2-sphere. \n",
"To visualize the Hopf fibration, we will choose some points on the 2-sphere $S^2$, draw their fibers and and see what they look like. Since these fibers lie in the 4d space we cannot see them directly, but if we project them to 3d space using the [stereographic projection](https://en.wikipedia.org/wiki/Stereographic_projection) then some remarkable structure appears. The fibers are projected to circles in 3d space (one of which in a line, comes from the fiber through infinity), any two such circles are linked with each other and the line passes through all circles. The 3d space is filled with nested tori made of linking Villarceau circles, each tori is the preimage of a circle of latitude of the 2-sphere. \n",
"\n",
"So our plan is:\n",
"\n",
Expand Down Expand Up @@ -360,7 +360,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.10.12"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
Expand Down
52 changes: 52 additions & 0 deletions src/misc/hopf_fibration.pov
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#version 3.7;

global_settings {
assumed_gamma 2.2
max_trace_level 10
}

#declare TubeThickness = 0.05;

#macro Torus(center, rad, mat, col)
torus {
rad, TubeThickness
texture {
pigment {
color col
}
finish {
ambient 0.4
diffuse 0.5
specular 0.6
roughness 0.1
reflection 0
}
}
matrix <mat[0].x, mat[0].y, mat[0].z,
mat[1].x, mat[1].y, mat[1].z,
mat[2].x, mat[2].y, mat[2].z,
0, 0, 0>
translate center
}
#end

union {
#include "torus-data.inc"
}

camera {
location <0, 0, 1> * 9
look_at <0, 0, 0>
right x*image_width/image_height
up y
sky y
}

light_source {
<0, 1, 1> * 100
color rgb 1
area_light
x*32, z*32, 5, 5
adaptive 1
jitter
}
8 changes: 2 additions & 6 deletions src/misc/lorenz.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ def derivative(point, t):

fig = plt.figure(figsize=(6.4, 4.8), dpi=100)
ax = fig.add_axes(
[0, 0, 1, 1],
projection="3d",
xlim=(-25, 25),
ylim=(-35, 35),
zlim=(5, 55)
[0, 0, 1, 1], projection="3d", xlim=(-25, 25), ylim=(-35, 35), zlim=(5, 55)
)
ax.set_box_aspect((1, 1, 1))
ax.view_init(30, 0)
Expand Down Expand Up @@ -90,5 +86,5 @@ def animate(i):
dpi=200,
bitrate=1000,
codec="libx264",
extra_args=["-crf", "10"],
extra_args=["-crf", "10", "-pix_fmt", "yuv420p"],
)
22 changes: 12 additions & 10 deletions src/misc/modulargroup.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,8 @@ class HyperbolicDrawing(cairo.Context):
"""

def set_axis(self, **kwargs):
surface = self.get_target()
width = surface.get_width()
height = surface.get_height()

width = kwargs.get("width", 800)
height = kwargs.get("height", 400)
xlim = kwargs.get("xlim", [-2, 2])
x_min, x_max = xlim
ylim = kwargs.get("ylim", [0, 2])
Expand Down Expand Up @@ -183,9 +181,11 @@ def main(width, height, depth, xlim=None, ylim=None):
xlim = [-2, 2]
if ylim is None:
ylim = [0, 2]
surface = cairo.ImageSurface(cairo.FORMAT_RGB24, width, height)
surface = cairo.SVGSurface("modulargroup.svg", width, height)
ctx = HyperbolicDrawing(surface)
ctx.set_axis(xlim=xlim, ylim=ylim, background_color=(1, 1, 1))
ctx.set_axis(
width=width, height=height, xlim=xlim, ylim=ylim, background_color=(1, 1, 1)
)
ctx.set_line_join(2)
# draw the x-axis
ctx.move_to(xlim[0], 0)
Expand All @@ -207,11 +207,13 @@ def main(width, height, depth, xlim=None, ylim=None):
triangle, facecolor=fc_color, linewidth=0.04 / (len(word) + 1)
)

surface.write_to_png("modulargroup.png")
surface.finish()

surface = cairo.ImageSurface(cairo.FORMAT_RGB24, width, height)
surface = cairo.SVGSurface("cayleygraph.svg", width, height)
ctx = HyperbolicDrawing(surface)
ctx.set_axis(xlim=xlim, ylim=ylim, background_color=(1, 1, 1))
ctx.set_axis(
width=width, height=height, xlim=xlim, ylim=ylim, background_color=(1, 1, 1)
)
ctx.set_line_join(2)
# draw the x-axis
ctx.move_to(xlim[0], 0)
Expand All @@ -237,7 +239,7 @@ def main(width, height, depth, xlim=None, ylim=None):
linewidth=0.02 / (1 + len(word)),
)

surface.write_to_png("cayley_graph.png")
surface.finish()


if __name__ == "__main__":
Expand Down

0 comments on commit ebed3f4

Please sign in to comment.