diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-07-14 21:15:32 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-07-14 21:15:32 +0200 |
| commit | ff0286325a3dd1f4fe7e29e78341b9bd63e1725c (patch) | |
| tree | 784b7ac282353a4d2b26f898c24f2f8cf2379975 /src/video-math.h | |
| parent | Fix blind-invert-matrix and increase percision of blind-to-text (diff) | |
| download | blind-ff0286325a3dd1f4fe7e29e78341b9bd63e1725c.tar.gz blind-ff0286325a3dd1f4fe7e29e78341b9bd63e1725c.tar.bz2 blind-ff0286325a3dd1f4fe7e29e78341b9bd63e1725c.tar.xz | |
blind-matrix-{rotate,shear}: add -d
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
| -rw-r--r-- | src/video-math.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/video-math.h b/src/video-math.h index 28ac4f2..47a6965 100644 --- a/src/video-math.h +++ b/src/video-math.h @@ -31,6 +31,50 @@ posmodf(float a, float b) return x < 0 ? x + b : x; } +static inline double +degsin(double u) +{ + if (!fmod(u, 90)) { + int64_t v = u; + v = ((v / 90) % 4 + 4) % 4; + return ((double[]){0, 1, 0, -1})[v]; + } + return sin(u * (M_PI / 180.0)); +} + +static inline float +degsinf(float u) +{ + if (!fmodf(u, 90)) { + int64_t v = u; + v = ((v / 90) % 4 + 4) % 4; + return ((float[]){0, 1, 0, -1})[v]; + } + return sin(u * (float)(M_PI / 180.0)); +} + +static inline double +degcos(double u) +{ + if (!fmod(u, 90)) { + int64_t v = u; + v = ((v / 90) % 4 + 4) % 4; + return ((double[]){1, 0, -1, 0})[v]; + } + return cos(u * (M_PI / 180.0)); +} + +static inline float +degcosf(float u) +{ + if (!fmodf(u, 90)) { + int64_t v = u; + v = ((v / 90) % 4 + 4) % 4; + return ((float[]){1, 0, -1, 0})[v]; + } + return cos(u * (float)(M_PI / 180.0)); +} + #define GENERIC(TYPE, FUNC, ...)\ TYPE: FUNC(__VA_ARGS__),\ TYPE *: FUNC(__VA_ARGS__),\ @@ -73,6 +117,8 @@ posmodf(float a, float b) #define sin(...) MATH_GENERIC_1(sin, __VA_ARGS__) #define tan(...) MATH_GENERIC_1(tan, __VA_ARGS__) #define atan2(...) MATH_GENERIC_N(atan2, __VA_ARGS__) +#define degcos(...) MATH_GENERIC_1(degcos, __VA_ARGS__) +#define degsin(...) MATH_GENERIC_1(degsin, __VA_ARGS__) #define srgb_encode(...) BLIND_GENERIC_1(srgb_encode, __VA_ARGS__) #define srgb_decode(...) BLIND_GENERIC_1(srgb_decode, __VA_ARGS__) |
