From 24afb2a24f97c412fc29b6ff6f67fa741f99aa49 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Thu, 12 Jan 2023 14:43:52 -0800 Subject: [PATCH] Fix angle_between --- manimlib/shaders/quadratic_bezier_stroke/geom.glsl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/manimlib/shaders/quadratic_bezier_stroke/geom.glsl b/manimlib/shaders/quadratic_bezier_stroke/geom.glsl index 1814a6ac..0d54d9a9 100644 --- a/manimlib/shaders/quadratic_bezier_stroke/geom.glsl +++ b/manimlib/shaders/quadratic_bezier_stroke/geom.glsl @@ -52,9 +52,16 @@ const float ANGLE_THRESHOLD = 1e-3; #INSERT rotate.glsl +float atan2(float y, float x){ + // Normally atan is undefined for x = 0 + if(x == 0) return sign(y) * 0.5 * PI; + return atan(y, x); +} + + float angle_between(vec2 v1, vec2 v2){ vec2 quot = complex_div(v2, v1); // Defined in get_xy_to_uv - return sign(quot.x) * atan(quot.y, quot.x); + return atan2(quot.y, quot.x); }