50 lines
2.9 KiB
Markdown
50 lines
2.9 KiB
Markdown
# Conformal Mapping and Video Generation
|
||
|
||
## What is the mapping?
|
||
|
||
1. Output image coordinates (x_img,y_img) normalized to [-0.5, 0.5] * [-0.5, 0.5] are multiplied by scale_in to obtain (x,y)
|
||
2. (x,y) is mapped to (u,v) using a conformal or similar mapping.
|
||
3. (u,v) is multiplied by scale_out, and then mapped to (u_tex, v_tex) such that the part inside [-0.5, 0.5] * [-0.5, 0.5] corresponds to the entire rectangular texture.
|
||
4. If (u_tex, v_tex) is a valid coordinate in the input texture, we output the (filtered) texel color, otherwise, we output the default color black.
|
||
|
||
## How to get the example results
|
||
|
||
Environment: Python 3.11. Do `pip install -r requirements.txt` to get necessary packages.
|
||
|
||
`python map2video.py color_rotate.png color_rotate.gif --num_frames 40`
|
||
|
||
`python map2video.py grid.jpg grid_holo.mp4 --num_frames 40 --map_type holo`
|
||
|
||
`python map2video.py grid.jpg grid_anti.mp4 --num_frames 40 --map_type antiholo`
|
||
|
||
`python map2video.py grid.jpg grid_exp.mp4 --num_frames 40 --map_type exp --scale_out 0.25 --scale_in 6.28`
|
||
|
||
`python map2video.py grid.jpg grid_log.mp4 --num_frames 40 --map_type log --scale_out 0.159 --scale_in 4`
|
||
|
||
The scale in and scale out parameters are chosen so that combining the two mapping should give the identity mapping.
|
||
|
||
## 关于标题“保角变换”
|
||
|
||
保角变换就是保持变换前后角度不变的变换。
|
||
|
||
前面提到、代码中实现的变换是反演变换([Inversion Transformation](https://en.wikipedia.org/wiki/Inversion_transformation)),和保角变换([Conformal Mapping](https://en.wikipedia.org/wiki/Conformal_map))很类似。
|
||
|
||
具体而言,代码里实现的反演变换
|
||
|
||
```
|
||
(x, y) -> ( x/(x*x+y*y), y/(x*x+y*y) )
|
||
```
|
||
|
||
把平面上的点映射到关于单位圆的对称点上:半径变为原来的倒数,角度不变。这个变换保持角度不变(但会镜像)
|
||
|
||
### 关于二维保角变换
|
||
|
||
二维平面中,映射保角的充要条件是对应的复变函数在解析(全纯)且导数不为零。如果映射对应的复变函数的共轭是全纯的,那么映射保角度但会让角的“方向”反向。
|
||
|
||
比如,对复变函数 $f(z) = e^z$,由于$f'(z)=e^z$,f 在全平面解析,所以带入 $z=x+iy$ 得到的映射$(x,y)\rightarrow (e^x\cos(y), e^x\sin(y))$ 就是一个保角映射。(选项 exp)
|
||
|
||
又比如复变函数 $f(z) = \log(z)$,解析,对应的映射是 $(x,y)\rightarrow (\log(x^2+y^2),\arctan(\frac{y}{x}))$,也保角(选项 log)
|
||
|
||
$(x,y)\rightarrow (\frac{x}{x^2+y^2}, \frac{y}{x^2+y^2})$ 对应的复变函数是 $f(z)=z/|z|^2=\frac{z}{z\bar{z}}=\frac{1}{|z|}$,可以证明它不解析。然而,它的共轭$\bar{f(z)}=\frac{1}{z}$是解析的,因为导数是 $\frac{d}{dz}(\frac{1}{z}) = -\frac{1}{z^2}$。因此,这是一个反方向的保角映射。(选项 antiholo)
|
||
|
||
$(x,y) \rightarrow (\frac{x}{x^2+y^2},\frac{-y}{x^2+y^2})$对应的复变函数是 $f(z)=\frac{1}{z}$,解析,因此这是一个真的保角映射。(选项 holo) |