Skip to content

Commit

Permalink
simplify readme and fix a bug in snub 24-cell
Browse files Browse the repository at this point in the history
  • Loading branch information
neozhaoliang committed Jan 4, 2020
1 parent 320817b commit 1eef17f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 133 deletions.
134 changes: 4 additions & 130 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,146 +17,20 @@

## About this repo

Math is beautiful, but to truly enjoy it one has to walk a long and painful way learning lots of boring stuff before he could see the full landscape. I hope this repo could help those people without a strong math background get some intuitive understanding of the beauty and elegance of math. The topics are chosen largely due to my personal taste:
The purpose of this project is to show the beauty of math with python. It consists of several independent sub-projects. The topics are chosen largely due to my personal taste:

1. They must produce appealing results.
2. There must be some non-trivial math behind them.
3. The code should be as simple as possible.

I'll use only popular python libs and build all math stuff by hand (tools like `sage`, `sympy`, `mathemetica` will not be used here).
I'll use only popular python libs and build all math stuff by hand (tools like `sage`, `sympy`, `mathemetica` will not be used here). Also I only maintain the code for `python >= 3.5`.

The website for the docs is still under construction and will be released soon.

**This repository will be always under construction since there are too many interesting things in math that can be shown by code.** Pull requests, issues, questions, and suggestions are all welcomed!

**NB:** I will only maintain the code for `python >= 3.5`.


## Examples

Here is *a very small portion* of examples that this project can do:

+ [Wilson's uniform spanning tree algorithm animation](./src/gifmaze/example_maze_animations.py)

<p align="center">
<a href="https://imgur.com/ptSqlDl"><img src="https://i.imgur.com/ptSqlDl.gif"/></a>
</p>

+ [Hilbert's curve animation](./src/gifmaze/example_hilbert_curve.py)

<p align="center">
<a href="https://imgur.com/gEO7AMR"><img src="https://i.imgur.com/gEO7AMR.gif" width="600"/></a>
</p>

+ [Domino shuffling algorithm animation](./src/aztec/run_domino_shuffling_animation.py)

<p align="center">
<a href="https://imgur.com/BWUBjto"><img src="https://i.imgur.com/BWUBjto.gif"/></a>
</p>

+ [Raymarching fractals](./src/fractal3d/fractal3d.py)

<p align="center">
<a href="https://imgur.com/yca2GAj"><img src="https://i.imgur.com/yca2GAj.png" width="600"/></a>
</p>

<p align="center">
<a href="https://imgur.com/Tts3ZUd"><img src="https://i.imgur.com/Tts3ZUd.png" width="600"/></a>
</p>

<p align="center">
<a href="https://imgur.com/O9Q3VOr"><img src="https://i.imgur.com/O9Q3VOr.png" width="600"/></a>
</p>

+ [Hopf fibration](./src/hopf/hopf_fibration.ipynb)

<p align="center">
<a href="https://imgur.com/hJJeone"><img src="https://i.imgur.com/hJJeone.png" width="600"/></a>
</p>

+ [Aperiodic tilings](./src/aperiodic-tilings)

<p align="center">
<a href="https://imgur.com/oJ5N06Z"><img src="https://i.imgur.com/oJ5N06Z.png" width="600"/></a>
</p>

<p align="center">
<a href="https://imgur.com/oLJQBU2"><img src="https://i.imgur.com/oLJQBU2.png" width="600"/></a>
</p>


+ [Langton's ant animation](./src/gifmaze/example_langton_ant.py)

<p align="center">
<a href="https://imgur.com/XwIg4QL"><img src="https://i.imgur.com/XwIg4QL.gif"/></a>
</p>


+ [Reaction-diffusion simulation](./src/grayscott/main.py)

<p align="center">
<a href="https://imgur.com/3dPrFa6"><img src="https://i.imgur.com/3dPrFa6.png" width="600"/></a>
</p>

<p align="center">
<a href="https://imgur.com/3fklRDM"><img src="https://i.imgur.com/3fklRDM.png" width="600"/></a>
</p>

+ [Uniform polytopes](./src/polytopes)

<p align="center">
<a href="https://imgur.com/CpfGucn"><img src="https://i.imgur.com/CpfGucn.png"/></a>
</p>

<p align="center">
<a href="https://imgur.com/pM1gePd"><img src="https://i.imgur.com/pM1gePd.png"/></a>
</p>

<p align="center">
<a href="https://imgur.com/fr69m1j"><img src="https://i.imgur.com/fr69m1j.gif"/></a>
</p>

<p align="center">
<a href="https://imgur.com/qeyPqMZ"><img src="https://imgur.com/qeyPqMZ.png"/></a>
</p>


+ [Uniform tilings](./src/uniform-tilings/example_uniform_tilings_2d.py)


<p align="center">
<a href="https://imgur.com/k5Prvkx"><img src="https://i.imgur.com/k5Prvkx.jpg" width="600"/></a>
</p>


<p align="center">
<a href="https://imgur.com/bwXoFBc"><img src="https://i.imgur.com/bwXoFBc.jpg" width="600"/></a>
</p>


<p align="center">
<a href="https://imgur.com/uK6jBmA"><img src="https://i.imgur.com/uK6jBmA.jpg" width="600"/></a>
</p>


<p align="center">
<a href="https://imgur.com/NtPeZDb"><img src="https://i.imgur.com/NtPeZDb.png" width="600"/></a>
</p>

<p align="center">
<a href="https://imgur.com/TBpYJnoc"><img src="https://i.imgur.com/TBpYJno.jpg" width="600"/></a>
</p>


<p align="center">
<a href="https://imgur.com/HaAI8ae"><img src="https://i.imgur.com/HaAI8ae.png" width="600"/></a>
</p>


+ [Möbius transformations in hyperbolic 3-space](./src/mobius/Mobius_in_H3space.py)
A few examples:

<p align="center">
<a href="https://imgur.com/U1XgWkc"><img src="https://i.imgur.com/U1XgWkc.png" width="600"/></a>
<img src="./gallery.png" width="800">
</p>


Expand Down
Binary file added gallery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions src/polytopes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,8 @@ class Snub24Cell(Polychora):

def __init__(self):
coxeter_diagram = (3, 2, 2, 3, 3, 2)
coxeter_matrix = helpers.make_symmetry_matrix(coxeter_diagram)
mirrors = helpers.get_mirrors(coxeter_diagram)
super().__init__(coxeter_matrix, mirrors, (1, 1, 1, 1), extra_relations=())
active = (1, 1, 1, 1)
super().__init__(coxeter_diagram, active, extra_relations=())
self.symmetry_gens = tuple(range(6))
self.symmetry_rels = ((0,) * 3, (2,) * 3, (4,) * 3,
(0, 2) * 2, (0, 4) * 2, (3, 4) * 2,
Expand Down

50 comments on commit 1eef17f

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You work is so interesting and excellent!

@neozhaoliang
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

很高兴看到你也喜欢埃舍尔风格的艺术,希望有机会多交流。

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

很高兴收到你的回复,偶遇对蕴含美学元素几何问题感兴趣的同道,欣喜异常。

赵博士学识渊博,涉猎广泛,娴熟的Python技术令人羡慕, 而且口齿伶俐,文采斐然,能把抽象晦涩的群论,结合具体几何问题,深入浅出,以图文并茂的方式科普,非常难得。昨天从Jos Leys的网页追过来,一不小心看了几个小时,特意注册了一个ID,有以下问题向你请教:
(1)给定满足1/p+1/q+1/r < 1 的三个自然数,可以唯一确定一个双曲对称群对庞加莱圆盘剖分,构造一个tiling,很多资料都详细介绍了具体的实现方法。另一方面,三维庞加莱球的对称群剖分问题,其存在条件,剖分算法等等,我还没看到(见过一些效果图),大致知道它的基础域由三个过球心的反射平面和一个反演球面围成。可以介绍一些文献,学习如何剖分庞加莱球吗?
(2)四维空间中有6个多胞体,分别为{3,3,3},{3,3,4},{4,3,3},{3,4,3},{3,3,5}和{5,3,3},它们分别有5,8,16,24,120,600个顶点。看了你的文章才知道,这些顶点的计算并不简单,编程实现的话,很费心血。可以请你运行一遍程序,传一份四维空间多胞体的详细顶点坐标给我吗(没有解析表达式的话,数值解也可以)?我想用这些顶点信息做一些实验。

上述两个问题都思考过一段时间,但一直没有解决,若赵博士可以施以援手,本人感激不尽 ^ _ ^

@neozhaoliang
Copy link
Owner Author

@neozhaoliang neozhaoliang commented on 1eef17f Jan 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你的第一个问题在 Roice 的论文中有部分回答,见 https://github.com/roice3/Honeycombs
简单说一个铺砌是双曲的、欧式的、有限的,可以通过其 Cartan 矩阵的惯性指数来判断。

我不太理解你指的 "如何剖分庞加莱球" 是什么意思,如果指的是求出铺砌中每个顶点坐标、边/面/胞腔的下标,那么这个项目已经做了这些。不过我在渲染的时候发现对上百万个顶点的场景计算所有精确信息非常费时间,所以后来的提交里面改成了浮点数比较胞腔中心去重的方法。之前的 commit 里面是把每个顶点、边、面、胞腔对应的群元素都计算了的。

我不建议采用用球面作为反射镜面,用反演变换作为反射的处理方式,这样做需要针对双曲空间单独处理。实际上不管是欧式、球面还是双曲铺砌,它们都可以通过在高一维的空间里面用一个超曲面去截对应 Coxeter 群的 Tit's cone 得到。欧式的情形这个超曲面是平面 z=c,球面的情形这个超曲面是单位球面,双曲的情形这个超曲面 hyperboloid. 这就是这个程序采取的处理方式,见 Gunnels 的论文 https://people.math.umass.edu/~gunnells/pubs/cells/cells.pdf
简单说,就是二维铺砌的基本区域可以通过在三维欧式空间里面摆放三个反射平面,用通常的线性变换来计算,然后投影到二维。三维铺砌的基本区域就是在四维欧式空间里面摆放四个反射平面,然后投影到三维。
这些基本区域都是通常意义下超平面之间所夹的凸锥。唯一需要注意的事情是反射的表达式

def reflect(normal, v):
    return v - 2 * dot(normal, v) * normal

中,内积 dot 必须是对应的欧式或者 Minkowski 度量下的内积。
Casselman 的讲义 http://www.math.ubc.ca/~cass/ 也是不错的参考资料。

"看了你的文章才知道,这些顶点的计算并不简单,编程实现的话,很费心血"。
其实对于非星状多面体的话,顶点和边面的计算很简单,编程实现的话也很容易,网上这样的代码比比皆是,难点在于怎样在不使用浮点数精度比较的前提下进行计算。这个项目里面提供了两种方法:Todd-Coxeter 算法和 Coxeter 自动机。这两个方法确实比较 "麻烦",但是从审美上讲它们更优雅,而且可以处理星状的情形,也可以很容易处理各种其它维数、snub 的情形。

我不太清楚你想要什么格式的数据文件? 实际上只要运行例子中的代码
https://github.com/neozhaoliang/pywonderland/blob/master/src/polytopes/run_4d_rotation_animation.py
就会在 povray 目录下生成一个 polytope-data.inc 的文件,这个文件里面包含了多胞体的所有数据,你可以查看这个文件来获得数据。这个脚本的 main 函数里面包含了各种各样的多胞体的例子。不过这个输出的格式是 povray 专用的,未必适用于你使用的渲染器。此外每个多胞体 P 都有 vertices_coords, edge_indices 等属性,你可以直接打印/导出查看其值。

再就是网上已经有人贴出了四维正多胞体的数据文件,比如这里:
http://paulbourke.net/geometry/hyperspace/
可能需要在程序中针对他的格式进行处理。

@OuyangPeichang
Copy link

@OuyangPeichang OuyangPeichang commented on 1eef17f Feb 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

发了一个邮件到您邮箱没收到回复,可能您对邮箱设置了邮件屏蔽,以下邮件内容,期待您的帮助:

赵博士:

 非常感谢感谢您的热心引导和解疑,我在逐步消化您回复的信息。

 今天安装了一个Python 3.7,可能安装不对,或者是其他编译问题(我只有编译调试c语言的经验),无法顺利运行pywonderland-master下子文件夹src中的12个程序。从随附的120-cell.png和gallery.png看,效果非常震撼。

 可以请您把povray 目录下生成的 polytope-data.inc 文件直接发给我吗?我非常希望可以得到4维多胞体的顶点信息(能用txt打开文件和浏览数据即可)。

 附件中是我们近期合成的一幅具有螺旋对称性的艺术图案,希望你会喜欢。

祝好

@neozhaoliang
Copy link
Owner Author

@neozhaoliang neozhaoliang commented on 1eef17f Feb 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

抱歉我的gmail邮箱确实把你的邮件归入了垃圾邮件,没有及时收到。现在国内封锁,我登录不了gmail查看附件。

在 .travis.yml 文件中有如何配置运行环境的说明 (readme 里面也有),这个项目在 python3.5, python3.6 和 ubuntu 16.04 下面都是测试通过的。windows 平台的话需要正确配置 povray 和 ffmpeg 的命令行才能运行。

我把数据文件传到了百度网盘上,链接为

链接: https://pan.baidu.com/s/1nni6F6dvTbbwCGmfCazxYg 提取码: ivxv

这是一个 grand stellated 120-cell 的数据文件,供 povray 渲染使用。

其中的边使用的是宏

Edge(i, v1, v2)

这里 i 是边的类型,由于这是一个均匀的星状多胞体所以一律是 0,后面的 v1,v2 对应的是边的两个端点在顶点序列中的整数下标。

面使用的是宏

Face(i, indices)

同样 i 是面的类型,一律是 0,后面的 indices 对应的是面的各个顶点在顶点序列中的整数下标。

祝你顺利。

@neozhaoliang
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我看到你们的作品了,很棒。这个图案也适用在 Escher 风格的欧式或者双曲铺砌当中。

@neozhaoliang
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polytopes 项目有比较大的修改,代码更紧凑整洁,博客中的文章也作了更新。之前有些注释是错误的。

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

非常非常感谢您发来的数据和详细解释!对于没有pathon经验,要正确安装和配置povray 和 ffmpeg ,感觉很难下手,非常茫然 ^ _ ^

我回顾了Coxeter的经典《Regular Polytopes》,已经得到四维正多胞体{3,3,3},{3,3,4},{4,3,3},{3,4,3}的顶点。昨天,结合网上的一些资源,找到了{3,3,5}和{5,3,3}顶点的优雅解析表达方式。

我注意到您发的是grand stellated 120-cell 的顶点数据(连接邻接顶点构成的星状几何体),而不是regular 的方式(即连接相邻的顶点可以构成凸多面体)。可以麻烦您再运行一次程序,把4-D regular polytopes中 {3,3,5}和{5,3,3}的顶点数据上传到网盘吗?这些顶点是我们实验中非常关键的数据。
祝好

@neozhaoliang
Copy link
Owner Author

@neozhaoliang neozhaoliang commented on 1eef17f Feb 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

120-cell 和 600-cell 对应的数据文件在这里:

链接: https://pan.baidu.com/s/1eRgWm8dOFGpKG53tDgTluQ 提取码: xxnm 

其实即便不安装 povray 和 ffmpeg,直接运行程序也会生成数据文件,只是不会渲染而已。可以去 povray 目录下找到 polychora-data.inc 或者 polytope-data.inc 文件即可。

或者找一台安装了 ubuntu 系统的电脑,按照 readme 文件里面的说明即可安装所有依赖。

regular-polychora

uniform-polychora

"我们" 的意思是你们是一个小组在做这方面的兴趣探索吗?

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

您的数据帮我节省了非常多繁琐的工作 ^_^, 非常感谢您的热心和慷慨!
您的程序非常棒,渲染的图形非常精美,有质感,美学效果令人震撼。
也许您已经注意到了,Jos Leys用Ultrafractal做了许多有关分形的渲染,见http://www.josleys.com/show_gallery.php?galid=334
我们正在准备基于c++的光线追踪渲染,之前没有技术储备,进展比较慢,下面是一张二维的反演图,效果不太好。
请问您的光线追踪代码可以直接移植,用于c++框架下的光线渲染吗?

数学造诣如此深厚,请问您是在IT行业,高校还是科研所呢?
我们有个小组在做一些感兴趣的东西,目前集中于Escher艺术,下面是我们近期得到的一个案例《攀登者》。
Climber

sphere_test

@neozhaoliang
Copy link
Owner Author

@neozhaoliang neozhaoliang commented on 1eef17f Feb 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我在企业里面做算法开发。

我的 3d 图像几乎都是使用 POV-Ray 这个光线追踪器渲染的,我个人于渲染一门是个菜鸟。渲染的效果好的话应该归功于 POV-Ray。josleys 的视频 dimensions 和 chaos 都是用 povray 制作的。

你们是打算制作 Escher 风格的作品来做商业开发吗?POVRAY 在 github 上是开源的,而且它是 C++ 开发的,它的协议里面规定只要是非商业目的都可以将其打包作为个人项目的一部分。

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

非常感谢你的回复,你真的太过谦了。
可以请你发给我现成的C++ POV-Ray 光线追踪器渲染代码吗?我们现在的渲染效果实在不敢恭维。
我们积累了一些Escher作品,想做瓷器工艺品开发,做了一些尝试,但不理想。目前在寻求厉害的瓷器艺术专家合作。
你可以用微信扫下面的码,链接中保持了一部分部分Escher图案。
weixin

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

四维正多胞体完全反射群的生成元很多文献有论述,但关于这些离散对称群的旋转群(用矩阵群表示的话,矩阵群众元素的行列式都是正1)的生成元我没有见过,你能列出这些旋转群的生成元的矩阵表示吗?或者你见过有文献讨论过吗?

@neozhaoliang
Copy link
Owner Author

@neozhaoliang neozhaoliang commented on 1eef17f Feb 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

您是老师带学生做项目吗?我觉得您的创意是很好的,坚持下去一定会实现理想。

渲染代码就在项目里:https://github.com/neozhaoliang/pywonderland/tree/master/src/polytopes/povray
这个项目使用的所有一切都是开源的,POV-Ray 是开源的,生成多胞体数据的 python 代码开源,生成博客文章中例子的 povray 渲染文件也开源。

但关于这些离散对称群的旋转群(用矩阵群表示的话,矩阵群众元素的行列式都是正1)的生成元我没有见过

多胞体的旋转群给出的新的多胞体很少,唯一的例外是 snub 24-cell,其它的 snub 类型给出的都是已知的截断多胞体。
snub 24-cell 在这里:
https://github.com/neozhaoliang/pywonderland/blob/master/src/polytopes/polytopes/models.py#L406
其中的 self.vwords 是每个顶点对应的单词,它是群中一个旋转,它的矩阵表示可以由一列单反射的乘积得出,不过代码中没有写。

把图案做到瓷器上的话,有一些细节需要注意,就是极限点附近那些像素模糊的部分尽量做到把手、底部、开口边缘处,你的图案中有一些是直接放在了瓷器的瓶身比较显眼的位置,这可能会影响视觉效果。此外尽量全部铺满,不留空白。可以参考 josleys 的图像:

http://www.josleys.com/show_image.php?galid=363&imageid=9940

根据 Riemann 映射定理,单连通区域总是共形等价的,所以你的图案总是可以映射到任何瓶身上,见这里:

https://github.com/zenorogue/newconformist

最后就是反演得到的图案,其不动点在中心位置,不太适合做图案,双曲铺砌这种极限点在边界的比较适合。

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢您的鼓励 ^_^ ,我们是高校教师,做一些有关数学美学的研究,主要是兴趣。

非常感谢您的宝贵建议,一语惊醒梦中人,非常受益,特别是单连通黎曼映射技术的高难度程序实现,我是第一次见到。

josleys的作品激发了我们做Escher瓷器的想法,目前这是一个空白,困难主要有以下几点:(1)难找到媲美Escher的瓷器制作匠人;(2)Escher图案的设计极难,国内还没发现有;(3)精良的Escher瓷器制作,需要计算机图形技术+数学+优秀设计师集体协作,目前各方面人手不足;(4)造价高昂。

下面是我们近期做的70cm*70cm瓷画,细节没做到位,离Escher艺术还有距离。
Uploading 瓷器.jpg…

@neozhaoliang
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请问你们是怎么设计图案的呢?借助 inkscape, autocad 之类的工具吗?

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有两类:(1)矢量设计工具如autocad,Adobe illustrator,Freehand,优点是方便修改,精准无误差,一个模板可多次使用,但是艺术逼真度稍逊;(2)Tessellation手工绘画后剪切,优点是有真实的艺术品位(如水彩画),缺陷是几乎很难规避手工误差(Escher也难避免),也无法一个模板多处使用。

@neozhaoliang
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我想了一下,如果有 svg 格式的图案原型的话,是可以用我这个程序,把 svg 格式中每个 path 元素变换到对应的位置上,得到一个 svg 格式的 Escher 铺砌的。
有人用类似的方法做过:http://www.mi.sanu.ac.rs/vismath/dunham/index.html
他用的是一个类似搜索群元素的方法,一个从中心多边形开始一层一层往外铺,只适用于 (p, q) 这种有直角的类型。

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,我了解Dunham的工作,这类处理算法的代价比较昂贵,优点是能得到矢量图。
我喜欢用png, jpg 或者bmp格式子图构造艺术镶嵌图,我觉得这比较便利美观, 更逼近艺术品。

@neozhaoliang
Copy link
Owner Author

@neozhaoliang neozhaoliang commented on 1eef17f Feb 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我印象有个 filter forge 好像有个 lua 插件可以做这个,找了一下:
https://www.filterforge.com/forum/read.php?PAGEN_1=2&TID=10269#nav_start
顺便我也想请教一下怎样设计 Escher 图案,有教程方便提供吗?

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢分享,与您交流收获颇丰,非常愉快。

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢您的分享。
我觉得设计Escher模板主要首先是要有天赋,通过刻苦训练,在迸发灵感时候才能设计,本质上属于艺术创作。Escher本人也是去西班牙阿尔布拉罕宫2次后才脑洞大开,迸发出大量灵感的。您可以去http://www.tess-elation.co.uk了解更多。

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

赵博士您好,4D多胞体的球极投影方法(即您用来展示多胞体的方法),可以把四维单位球面 x^2+y^2+z^2+w^2=1 上的点投影到三维空间,虽然这种投影无法维持欧氏度量,但却可以维持四维空间中顶点和边的大部分拓扑信息,是一种展示高维多胞体的优美投影。您还知道4D空间中别的投影方法吗?我指的是可以尽可能保持多胞体美学特征的投影。

Jos leys在http://images.math.cnrs.fr/Un-ballon-de-foot-fractal.html?lang=fr中展示了许多与多面体密切相关的精美分形图案(我第一次看到时非常震撼到了),您知道这些图案的构造算法吗?文中他只对最简单的立方体生成算法做了较为详细描述。您所使用的代码能否渲染处这种效果(Jos leys说他是用Ultra工具的光线追踪技术)?

@neozhaoliang
Copy link
Owner Author

@neozhaoliang neozhaoliang commented on 1eef17f Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

据我所知,还有一种直接正交投影到一个平面的方法,但是不如球极投影好。

你说的 Jos Leys 的方法,是一种现在很流行很著名的方法,叫做 raymarching,这种方法不关心顶点边面的坐标,只关心每个像素的颜色。
我的项目中 example_wythoff_shader_animation.py 这个程序就是用这个方法生成的。
这种方法用到的技巧主要是构造场景的 distance field,然后结合一些光照模型做渲染。
Jos leys 的作品已经属于比较简单的了。
以下是几个例子,全部是用 raymarching 的技术纯代码生成的:

https://www.shadertoy.com/view/lt3cz7

https://www.shadertoy.com/view/tt2XzG

https://www.shadertoy.com/view/4ttSWf

https://www.shadertoy.com/view/XtcyW4

这个项目里面的 fractal3d 目录下面的其中一个演示在这里:

https://www.shadertoy.com/view/WssSWn

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

特别喜欢你关于Möbius 变换的介绍,前面的大部分图我都做过,但对于第三种“ z→cz 的斜航型变换扩展到 H3 后作用在一个圆柱体上的效果”,从没有想到过。如果给你一些具有平面晶体群对称性的Escher图案,你可以把它映射到圆柱上去吗?

这些天在思考能否用挖掘四元数的美学潜力,你知道四元数群的矩阵生成元表示吗?有没有可能在四维空间中构造具有螺旋对称性的几何图案(因四元素与复数类似,也可以表示螺旋变换,但是更为复杂和抽象)?

查看你早年的文章,其中有很多精美整洁的插图,这些图案是用什么软件绘制的呢?有没有容易上手的矢量绘图工具介绍?

@neozhaoliang
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hopf_fibration

我能想到的是 Hopf 纤维丛。这个在项目里面有。

第一个问题如果指的是普通的欧式圆柱体是可以的。POV-Ray 的 uv_texture 可以替你做。glsl 的话需要自己手动映射。Dupin cyclide 我不确定。

我绘图一般都用 matplotlib 或者 piscript: https://www.math.ubc.ca/~cass/piscript/

矢量绘图的话我推荐 piscript, 这个对 latex 支持特别好,缺点就是不太好用. "容易上手的矢量绘图工具" 没有。

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢您的回复和细心介绍,偶然情况下,我们曾构造过 Dupin cyclide蜘蛛网tiling(见下图),但之前不知道它有这个深刻的背景。
fig04b.pdf

我看过Jos leys关于hopf纤维丛的视频,很漂亮。模糊感觉可以考虑四元数的对称群和基础域,构造更精细的对称图。

我发了一个周期壁纸群包到您邮箱(若没收到,请提醒下),因部分图案涉及版权,不方便这里上传,可否把我邮箱[email protected]加入白名单?若代码量简单、您也有兴趣,可否帮我做纹理映射,试试圆柱上的Escher图案效果?

@neozhaoliang
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你可以参考这个网页中的例子:http://www.f-lohmueller.de/pov_tut/tex/tex_570e.htm
里面附有 POV-Ray 的代码。

@OuyangPeichang
Copy link

@OuyangPeichang OuyangPeichang commented on 1eef17f Aug 1, 2020 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neozhaoliang
Copy link
Owner Author

@neozhaoliang neozhaoliang commented on 1eef17f Aug 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果你是用 C++ 写的话,无论采用什么方法这个工作都很难。python, shader, C#, javascript 都可以,实在不行用 java 也可。

想了解用有限状态机绘制铺砌的话,最好还是去看 Casselman 的文章,在我的博客文章 http://pywonderland.com/coxeter-groups-and-uniform-tilings/ 最后给出了链接。这种方法数学比较复杂,需要比较多的数学知识才能掌握,不见得适合所有人。

传统的反复迭代反射的方法做的比较好的是 Roice 的项目

https://github.com/roice3/TilingBot
https://github.com/roice3/Honeycombs

这两个代码量比较大,理解起来也不是件容易的事情。

你可以先从 shadertoy 上找些例子来看看,理解其中的大致步骤。shadertoy 上关于铺砌的例子很多的。

首先要知道三种铺砌都可以在更高一维的空间里面通过求 tit's cone 和一个低维空间的超曲面的交来得到。见
https://www.ams.org/notices/200605/fea-gunnells.pdf

@OuyangPeichang
Copy link

@OuyangPeichang OuyangPeichang commented on 1eef17f Aug 1, 2020 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neozhaoliang
Copy link
Owner Author

@neozhaoliang neozhaoliang commented on 1eef17f Aug 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coxeter 群的方式比较优雅,可以输出矢量图形,代价就是数学复杂,而且计算 Coxeter 群的极小根只对比较小的 (p,q,r) 适用,pqr 大了以后计算量指数级增长。像素计算法则没有这个问题。我采用这个方法主要是考虑到网上还有这样的程序,想写一个有新意的,其实它的局限也很大,主要是渲染非常费时间。我正在考虑加入像素计算法的部分。

这里有一个二维双曲铺砌的项目:http://www.morenaments.de/hyp
用 Java 实现的,效果不错,而且有博士论文解释。

DonHatch 的项目也不错,还有 Curved Space,Zenrogue 这些比较有特色的开源项目。

根据我的体会,Roice 的项目效果最好,Zenrogue 的项目内容最丰富 (包含的数学更多),Curved Space 也不错。

shadertoy 上有一个渲染 honeycomb 的项目 https://www.shadertoy.com/view/XddyR2 也是一个不错的参考。

还有一个必须提到的是 Fragmentarium 这个软件
https://github.com/Syntopia/Fragmentarium
这个软件里面自带了不少有趣的双曲几何的例子,非常值得一看。其中在 fractalforums 上的讨论也很有价值。

关于开源项目我觉得有参考价值的基本只有这些,我的项目里面还有改编自 Matt Zucker 的两个 shader 程序,也是可以参考的。

我的建议是不必钻研开源项目的实现细节,那太费精力了。重点在理解其中的数学和他们的实现途径上,最终权衡比较选一个合适的。

你们关于多面体的研究是告一段落了吗?是否取得了满意的结果?

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢您的细致回复。

Martin von Gagern的工作我了解一些,他用德文写论文,一些细节我了解不到。

钻研技术实现不是我的特长(也学不来),平面欧氏空间,球面空间和双曲平面的万花筒原理我都实现过,但是semi-regular tiling没有做过。

高维双曲几何tiling非常优美,常常给人震撼的感觉,比如您给的链接,我非常喜欢。您提到用高维切面观察平面tiling结构的作法非常美。

现在想研究semi-regular tiling,用于实现一个具有精细螺旋对称性的Escher艺术案子,附件中有一个类似程序,我大概想在这个基础上实现自己的idea。

KaleidoTile-3-10-0-Win.zip

很遗憾,高维多胞体项目卡壳了。我们想实现四维以上多胞体反演(类似于你做的三维效果),并生成具有多胞体对称性的混沌吸引子。我们用简单的多项式来构造equivariant

动力系统,但程序运行中发现,由于无法判定多项式是否具有充分的混沌特征,很难产生有趣的吸引子。我们期望通过高维李雅普诺夫指数来引导动力系统的参数选择,目前没有

实现李雅普诺夫指数的计算(与平面或三维不同,高维李雅普诺夫指数不好实现)。

@neozhaoliang
Copy link
Owner Author

@neozhaoliang neozhaoliang commented on 1eef17f Aug 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不同的铺砌之间的区别只在于初始顶点的的位置。初始顶点位于基本区域的顶点处得到的是 regular ,位于某个边的中点处得到的是 truncated/rectified,位于中心得到的是 omnitruncated,这些之间没有本质区别。

MVG 的论文是有英文版的,我之前看过,他用的是像素法和 Knuth-Bender 约化。KB 方法也是去找 Coxeter 群的 word 的标准形式,不过不如 Brink-Howlett 的自动机方法优雅。

顺便我搭建了一个论坛
h3space.cn
你可以注册并在上面讨论数学方面的话题。

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

非常感谢您的提示,让我看清更多细节。

我阅读过MVG的少量英文论文,德国人做事严谨,印象比较深刻。

用群论的方法找出几何变换的简约表示,数学上非常优美,但我只理解大致意思,无法编写程序寻找出具体群元素。我的方法主要是基于几何意义,形象直观地完成tiling构造。

非常感谢您搭建的平台,3D双曲空间我比较陌生,甚至感觉其中的紧致型tiling构造算法仍然有许多未解问题(不知是否如此),期待您的分享。

@neozhaoliang
Copy link
Owner Author

@neozhaoliang neozhaoliang commented on 1eef17f Aug 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3D 双曲空间与 2d 没有本质区别,只不过是 hyperboloid 模型上加了一维。
"紧致型tiling构造算法仍然有许多未解问题",这个情形其实没有什么未解决问题。
从像素迭代方法开始也是不错的,我建议先从 fragmentarium 这个软件开始,看看它的代码实现,对整个过程有个直观了解,当然你需要花点时间了解下 raymarching 技术的原理。

http://blog.hvidtfeldts.net/index.php/category/fragmentarium/page/2/

http://blog.hvidtfeldts.net/index.php/2012/02/distance-estimated-polychora/

这个软件在 github 上开源,可以直接下载安装,然后运行它的 examples 目录下面的例子,上面博客里面的图形大部分在 example 里面都有。

然后可以去看 Roice 的 Honeycomb 项目。那个项目能看完的话就基本掌握双曲几何图案绘制的技巧了。

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

非常感谢您的分享,从中我追踪到许多非常感兴趣的材料,很多思想对我来说是大开脑洞的。

我需要先消化理论,编程技术方面我很难跟上,我会让合作伙伴解决。

如果有卡壳的地方继续向您请教 ^_^

再次感谢。

@neozhaoliang
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我发现一个不错的用图像铺砌双曲圆盘的项目:https://philogb.github.io/page/hyperfloors/
源代码可以右键查看网页源码,在 bundle.js 里面。

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

非常感谢您的分享。我对hypebolic tiling 特别感兴趣,非常遗憾的是我打不开其中的链接“Read the full article to learn more about this project.”
是需要翻墙吗?您能把这篇文章转给我吗?

@neozhaoliang
Copy link
Owner Author

@neozhaoliang neozhaoliang commented on 1eef17f Aug 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要翻墙。以下是网页截图。可以下载以后放大看。

Screenshot_2020-08-30 Hyperbolic Floors(1)

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢您的转文,一些技术细节非常有启发性,可以帮我找到贴图尾部沿着边界的复积分变换的数学原理描述吗?

作者的研究很吸引人,可以帮我把下面附图的内容也转给我吗(似乎作者还做了一个circle packing的研究)?我还是打不开。

第一张图令我很自然想起circle packing + fractal,Dunham发表了几篇有趣的相关研究(见附文),虽然思想和方法非常简单,但得到的图案非常有震撼力。

凑巧的是,在双曲空间嵌入欧氏周期图案的想法几年前我也产生过---原因在于这能把人们积累的成千上万欧氏周期图案转换到双曲空间,但因精力限制没有实践。

The Art of Random Fractals bridges2014-79.pdf
Fractal Wallpaper Patterns bridges2015-183.pdf
New Kinds of Fractal Patterns bridges2017-111.pdf

pp

@neozhaoliang
Copy link
Owner Author

@neozhaoliang neozhaoliang commented on 1eef17f Aug 31, 2020 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

非常感谢。

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omnitruncated-4-2-5
请教双曲tiling的构造方法问题(最好不用Wythoff构造原理):
(1)如何构造regular hyperbolic tiling?即tiling的所有tile是一个正多边形。
(2)如何找出“恰当的”双曲变换(双曲平移变换),将图中红色、黄色与绿色正多边形,覆盖整个庞加莱圆盘?
谢谢 ^&^

@neozhaoliang
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下次再开一个 issue 吧,这个网页已经被拉的很长了。

正则铺砌只要指定 active mirror 参数中第一个为 -1,后面两个是 0 就行了。例如

https://github.com/neozhaoliang/pywonderland/blob/master/src/uniform-tilings/example_uniform_tilings_2d.py#L38

"如何找出“恰当的”双曲变换(双曲平移变换)"

任何两个相同的正多边形之间应该是相差一个双曲空间里的旋转和平移。你可以把一个多边形移动到原点,旋转一定角度,然后移动到另一个的中心处。这可以用一个 Mobius 变换来实现。

你可以参考 Roice 项目里面的代码:

双曲放缩 https://github.com/roice3/Honeycombs/blob/master/code/R3/R3.Core/Math/Mobius.cs#L180
双曲平移 https://github.com/roice3/Honeycombs/blob/master/code/R3/R3.Core/Math/Mobius.cs#L167
双曲旋转 https://github.com/roice3/Honeycombs/blob/master/code/R3/R3.Core/Math/Mobius.cs#L96

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

第二个问题的解决方案都不太简单,可能也解决不了问题,感谢您的细致回复。

期待你新开一个有趣的议题。

@neozhaoliang
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我下面应该会补上双曲蜂巢的非紧致情形的部分,然后写一个关于扭结的项目。但是工作缠身难以有时间专注于此。

Roice 的项目不太好读,但是他的立意是很不错的,用 Mobius 变换、球反演来表示反射的优点是可以避免精度损失,毕竟双曲空间中的正交矩阵其元素可以是无界的,很可能超出 double 的精度。
此外 Roice 的项目也是参考了许多其它项目,本身也是汇集了很多人的想法。他的 tilingbot 项目和 honeycomb 项目应该是涵盖了你所想要的全部效果,并且出来的图像非常漂亮,所以我还是建议你参考他的实现方式。

你可以关注他的 Twitter 主页,上面每天都会自动发布这两个项目生成的图像。

@OuyangPeichang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roice的VISUALIZING HYPERBOLIC HONEYCOMBS 写的非常好,深入浅出,很有启发性,他对双曲蜂巢的探索已经超越了我的想象,期待你的进一步挖掘。

扭结理论我主要看到的是美学上的应用,很希望有一篇综述性、概括性的文章做一个纵览,期待你的工作。

github的结构我不熟悉,感觉不太友好,完全是追你的工作才进来的。

我现在思考的是在双曲空间嵌入一个精细的结构,用于实现Escher艺术,期望看到更多有关2维双曲几何的工作。

@neozhaoliang
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

开 issue 的话在这里:#28

github 是一个很好用的工具,只需要多用就习惯了。

Please sign in to comment.