From fdd0df09ed0cec56c6a7abee558f9428a1f577ba Mon Sep 17 00:00:00 2001 From: William Candillon Date: Wed, 25 Dec 2019 19:56:54 +0100 Subject: [PATCH] =?UTF-8?q?fix(=E2=99=BE):=20Remove=20functions=20that=20c?= =?UTF-8?q?an=20now=20be=20used=20directly=20from=20Reanimated=20(#145)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 28 --------------------- src/Math.ts | 46 ---------------------------------- src/bezier/CubicBezierSolve.ts | 5 ++-- 3 files changed, 3 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index 3c6c7597..0ad65919 100644 --- a/README.md +++ b/README.md @@ -162,16 +162,6 @@ Returns 1 if the difference between the two values is less than precision. Otherwise returns 0. Default value for the precision is 0.001. -### `atan(node: Node): Node` - -Returns the arc-tangent of the value in radians of the given node. -We provide this function in case you are using a version of reanimated that doesn't ship `atan`. -Beware that this function is not as precise at `Math.atan()` nor `Animated.atan()`. - -```js -atan(rad: Node) => Node -``` - ### `atan2(node: Node): Node` Returns the angle in the plane (in radians) between the positive x-axis and the ray from (0,0) to the point (x,y), `atan2(y,x)`. @@ -180,24 +170,6 @@ Returns the angle in the plane (in radians) between the positive x-axis and the atan2(y: Node, x Node) => Node ``` -### `acos(node: Node): Node` - -Returns the arc-cosine of the value in radians of the given node. -We provide this function in case you are using a version of reanimated that doesn't ship `acos`. - -```js -acos(y: Node, x Node) => Node -``` - -### `asin(node: Node): Node` - -Returns the arc-sinus of the value in radians of the given node. -We provide this function in case you are using a version of reanimated that doesn't ship `cos`. - -```js -asin(y: Node, x Node) => Node -``` - ### `cubicBezier(t: Node, p0: Node, p1: Node, p2: Node, p3: Node): Node` Returns the coordinate of a cubic bezier curve. diff --git a/src/Math.ts b/src/Math.ts index 20025ec3..8e086b85 100644 --- a/src/Math.ts +++ b/src/Math.ts @@ -4,7 +4,6 @@ const { Value, block, set, - sqrt, cond, add, multiply, @@ -91,51 +90,6 @@ export const atan2 = ( ]); }; -// https://developer.download.nvidia.com/cg/atan.html -export const atan = (x: Animated.Adaptable): Animated.Node => - atan2(x, 1); - -// https://developer.download.nvidia.com/cg/acos.html -export const acos = (x1: Animated.Adaptable) => { - const negate: Animated.Value = new Value(); - const x: Animated.Value = new Value(); - const ret: Animated.Value = new Value(); - return block([ - set(negate, lessThan(x, 0)), - set(x, abs(x1)), - set(ret, -0.0187293), - set(ret, multiply(ret, x)), - set(ret, add(ret, 0.074261)), - set(ret, multiply(ret, x)), - set(ret, sub(ret, 0.2121144)), - set(ret, multiply(ret, x)), - set(ret, add(ret, 1.5707288)), - set(ret, sqrt(sub(1, x))), - set(ret, sub(ret, multiply(2, negate, ret))), - add(multiply(negate, Math.PI), ret) - ]); -}; - -// https://developer.download.nvidia.com/cg/asin.html -export const asin = (x1: Animated.Adaptable) => { - const negate: Animated.Value = new Value(); - const x: Animated.Value = new Value(); - const ret: Animated.Value = new Value(); - return block([ - set(negate, lessThan(x, 0)), - set(x, abs(x1)), - set(ret, -0.0187293), - set(ret, multiply(ret, x)), - set(ret, add(ret, 0.074261)), - set(ret, multiply(ret, x)), - set(ret, sub(ret, 0.2121144)), - set(ret, multiply(ret, x)), - set(ret, add(ret, 1.5707288)), - set(ret, sub(Math.PI / 2, multiply(sqrt(sub(1, x)), ret))), - sub(ret, multiply(2, negate, ret)) - ]); -}; - export const cubicBezier = ( t: Animated.Node, p0: Animated.Node, diff --git a/src/bezier/CubicBezierSolve.ts b/src/bezier/CubicBezierSolve.ts index 95979711..5a5937da 100644 --- a/src/bezier/CubicBezierSolve.ts +++ b/src/bezier/CubicBezierSolve.ts @@ -1,7 +1,7 @@ import Animated from "react-native-reanimated"; import { find } from "../Array"; -import { acos, approximates } from "../Math"; +import { approximates } from "../Math"; const { Value, @@ -19,7 +19,8 @@ const { set, sub, cos, - not + not, + acos } = Animated; const isRootValidForCubicBezier = (root: Animated.Node) =>