Skip to content

Commit

Permalink
fix(♾): Remove functions that can now be used directly from Reanimated (
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon authored Dec 25, 2019
1 parent be11cb8 commit fdd0df0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 76 deletions.
28 changes: 0 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`.
Expand All @@ -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.
Expand Down
46 changes: 0 additions & 46 deletions src/Math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const {
Value,
block,
set,
sqrt,
cond,
add,
multiply,
Expand Down Expand Up @@ -91,51 +90,6 @@ export const atan2 = (
]);
};

// https://developer.download.nvidia.com/cg/atan.html
export const atan = (x: Animated.Adaptable<number>): Animated.Node<number> =>
atan2(x, 1);

// https://developer.download.nvidia.com/cg/acos.html
export const acos = (x1: Animated.Adaptable<number>) => {
const negate: Animated.Value<number> = new Value();
const x: Animated.Value<number> = new Value();
const ret: Animated.Value<number> = 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<number>) => {
const negate: Animated.Value<number> = new Value();
const x: Animated.Value<number> = new Value();
const ret: Animated.Value<number> = 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<number>,
p0: Animated.Node<number>,
Expand Down
5 changes: 3 additions & 2 deletions src/bezier/CubicBezierSolve.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -19,7 +19,8 @@ const {
set,
sub,
cos,
not
not,
acos
} = Animated;

const isRootValidForCubicBezier = (root: Animated.Node<number>) =>
Expand Down

0 comments on commit fdd0df0

Please sign in to comment.