Skip to content

Commit b998a4a

Browse files
committed
Update readme and small refactor
1 parent e4d9b3d commit b998a4a

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
1-
# complex
1+
# Complex
22
Complex number plotter using domain coloring
3+
4+
## Usage
5+
1. `git clone https://github.com/Ducolnd/complex`
6+
2. `cd complex`
7+
3. Install python 3 and virtualenv
8+
4. `virtualenv venv`
9+
5. `source venv/bin/activate`
10+
6. `pip install -r requirements.txt`
11+
7. Open complex.py and edit `function` function
12+
8. Run by typing `python complex.py` and close by pressing ECS
13+
14+
## Sources
15+
[algorithm-archive.org](https://www.algorithm-archive.org/contents/domain_coloring/domain_coloring.html)
16+
[dynamicmath.xyz](https://www.dynamicmath.xyz/domain-coloring/#basic)
17+
[wikipedia.org](https://en.wikipedia.org/wiki/Domain_coloring)

complex.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@
88
res = np.linspace(-2, 2, size * 2 + 1)
99
ims = np.linspace(-2, 2, size * 2 + 1)
1010

11-
1211
nums = np.zeros((len(res) - 1, len(ims) - 1), dtype=np.complex_)
1312

1413
for i in range(-size, size):
1514
for j in range(-size , size):
1615
nums[i+size, j+size] = complex(res[i+size], ims[j+size])
1716

17+
18+
# Edit this
1819
def function(complex_num):
1920
return complex_num ** 2
2021

22+
23+
2124
nums = function(nums)
2225

2326
phase = np.angle(nums, True)
@@ -26,7 +29,6 @@ def function(complex_num):
2629

2730
H = np.interp(phase, (-180, 180), (0, 360))
2831
S = 0.7 + (1 / 3) * (np.log(magnitude) / np.log(1.6) - np.floor(np.log(magnitude) / np.log(1.6))) # alternatively S = 0.5 + 0.5 * (magnitude - np.floor(magnitude))
29-
3032
V = ((np.abs(np.sin(math.pi * nums.real)) ** 0.1) * (np.abs(np.sin(math.pi * nums.imag)) ** 0.1)) * 255 # alternatively V = np.full(phase.shape, 255, dtype="float32")
3133

3234

0 commit comments

Comments
 (0)