Skip to content

Commit

Permalink
💚 (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon authored Dec 25, 2019
1 parent 84977d8 commit be11cb8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/Coordinates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ export interface PolarPoint {
radius: Animated.Adaptable<number>;
}

export const canvas2Cartesian = ({ x, y }: Point, center: Point): Point => {
export const canvas2Cartesian = ({ x, y }: Point, center: Point) => {
return {
x: sub(x, center.x),
y: multiply(sub(y, center.y), -1)
};
};

export const cartesian2Canvas = ({ x, y }: Point, center: Point): Point => ({
export const cartesian2Canvas = ({ x, y }: Point, center: Point) => ({
x: add(x, center.x),
y: add(multiply(y, -1), center.y)
});

export const cartesian2Polar = ({ x, y }: Point): PolarPoint => {
export const cartesian2Polar = ({ x, y }: Point) => {
return {
alpha: atan2(y, x),
radius: sqrt(add(pow(x, 2), pow(y, 2)))
};
};

export const polar2Cartesian = ({ alpha, radius }: PolarPoint): Point => ({
export const polar2Cartesian = ({ alpha, radius }: PolarPoint) => ({
x: multiply(radius, cos(alpha)),
y: multiply(radius, sin(alpha))
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
cartesian2Canvas,
cartesian2Polar,
polar2Cartesian
} from "./Coordinates";
} from "../Coordinates";

jest.mock("react-native-reanimated");

Expand Down
2 changes: 1 addition & 1 deletion src/Math.test.ts → src/__tests__/Math.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-underscore-dangle */
import { atan2 } from "./Math";
import { atan2 } from "../Math";

jest.mock("react-native-reanimated");

Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import "./Coordinates.test";
import "./Math.test";
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"allowSyntheticDefaultImports": true,
"types": ["react", "react-native"]
},
"files": ["src/index.d.ts"],
"files": ["src/index.d.ts", "src/__tests__/index.ts"],
"include": ["src/index.ts", "node_modules/@types/jest"]
}

0 comments on commit be11cb8

Please sign in to comment.