mirror of
https://github.com/3b1b/manim.git
synced 2025-08-01 17:29:06 +08:00
Fix angle_between
This commit is contained in:
@ -52,9 +52,16 @@ const float ANGLE_THRESHOLD = 1e-3;
|
|||||||
#INSERT rotate.glsl
|
#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){
|
float angle_between(vec2 v1, vec2 v2){
|
||||||
vec2 quot = complex_div(v2, v1); // Defined in get_xy_to_uv
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user