This file contains 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
def quick_sort(s: list, start: int, end: int): | |
if start < end: | |
pos = start | |
for i in range(start, end): | |
if s[i] < s[end]: | |
s[i], s[pos] = s[pos], s[i] | |
pos += 1 | |
s[pos], s[end] = s[end], s[pos] |
This file contains 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
#define BINARY_REFINEMENT 1 | |
#define BINARY_COUNT 4 | |
#define BINARY_DECREASE 0.5 | |
vec3 diagonal(mat4 mat) { return vec3(mat[0].x, mat[1].y, mat[2].z); } | |
vec3 projectionOrthogonal(mat4 mat, vec3 v) { return diagonal(mat) * v + mat[3].xyz; } | |
vec3 viewToScreen(vec3 viewPos) { | |
return (projectionOrthogonal(gbufferProjection, viewPosition) / -viewPosition.z) * 0.5 + 0.5; | |
} |
This file contains 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
#define EPS 1e-4 | |
#define PI 3.14159265 | |
#define INV_PI 0.31830988 | |
float maxEps(float x) { return max(EPS, x); } | |
float clamp01(float x) { return clamp(x, 0.0, 1.0); } | |
float pow2(float x) { return x*x; } | |
vec3 pow2(vec3 x) { return x*x; } |