This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import collections | |
| import mpmath as mp | |
| import matplotlib.pyplot as plt | |
| mp.dps = 100 | |
| alpha = beta = 2.2 | |
| sq2 = mp.sqrt(2) | |
| gamma = (alpha * beta + mp.sqrt(alpha * alpha * beta * beta + 8 - 4 * (alpha * alpha+beta*beta)) )/ 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sympy import * | |
| x, y, X, Y = symbols("x y X Y") | |
| P = x**2 + y**2 - 1 | |
| dx = diff(P, x) # gradient of P | |
| dy = diff(P, y) | |
| curve = Matrix([x, y]) | |
| light_source = Matrix([1, 0]) | |
| l = curve - light_source # the incident ray | |
| n = Matrix([dx, dy]) # the normal vector |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| Simple Hyperbolic tiling animation using taichi | |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| """ | |
| import taichi as ti | |
| from taichi.math import * | |
| ti.init(arch=ti.cpu) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cv2 | |
| import cairocffi as cairo | |
| import numpy as np | |
| import taichi as ti | |
| ti.init(arch=ti.cpu) | |
| scale = 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # pip install taichi | |
| import taichi as ti | |
| ti.init(arch=ti.gpu) | |
| d = 3 | |
| num_rounds = 100000 | |
| max_steps = 1000000 | |
| ivec = ti.types.vector(d, int) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import taichi as ti | |
| import taichi.math as tm | |
| ti.init(arch=ti.vulkan) | |
| w, h = 800, 640 | |
| res = (w, h) | |
| pixels = ti.Vector.field(3, float, shape=res) | |
| window = ti.ui.Window("fractal", res=res) | |
| canvas = window.get_canvas() |