From 80f7f1cd775a88d32e5f8e349a2c2371583c7e07 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Thu, 26 Dec 2019 10:17:49 +0100 Subject: [PATCH] =?UTF-8?q?fix(=F0=9F=90=9B):=20bug=20in=20atan2()=20(#147?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Math.ts | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/Math.ts b/src/Math.ts index 36113c55..b7efc63c 100644 --- a/src/Math.ts +++ b/src/Math.ts @@ -65,15 +65,12 @@ export const toDeg = (rad: Animated.Adaptable): Animated.Node => // https://developer.download.nvidia.com/cg/atan2.html const atan2Proc = proc( - ( - x: Animated.Adaptable, - y: Animated.Adaptable, - t0: Animated.Value, - t1: Animated.Value, - t3: Animated.Value, - t4: Animated.Value - ) => - block([ + (x: Animated.Adaptable, y: Animated.Adaptable) => { + const t0: Animated.Value = new Value(); + const t1: Animated.Value = new Value(); + const t3: Animated.Value = new Value(); + const t4: Animated.Value = new Value(); + return block([ set(t3, abs(x)), set(t1, abs(y)), set(t0, max(t3, t1)), @@ -92,19 +89,14 @@ const atan2Proc = proc( set(t3, cond(lessThan(x, 0), sub(Math.PI, t3), t3)), set(t3, cond(lessThan(y, 0), multiply(t3, -1), t3)), t3 - ]) + ]); + } ); export const atan2 = ( y: Animated.Adaptable, x: Animated.Adaptable -): Animated.Node => { - const t0: Animated.Value = new Value(); - const t1: Animated.Value = new Value(); - const t3: Animated.Value = new Value(); - const t4: Animated.Value = new Value(); - return atan2Proc(x, y, t0, t1, t3, t4); -}; +): Animated.Node => atan2Proc(x, y); export const cubicBezier = ( t: Animated.Adaptable,