@khanacademy/kmath 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,44 +0,0 @@
1
- /**
2
- * Flowtype definitions for data
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- /**
8
- * Number Utils
9
- * A number is a js-number, e.g. 5.12
10
- */
11
- declare export var DEFAULT_TOLERANCE: 1e-9;
12
- declare export var EPSILON: number;
13
- declare export function is(x: any): boolean;
14
- declare export function equal(
15
- x: number,
16
- y: number,
17
- tolerance?: number
18
- ): boolean;
19
- declare export function sign(x: number, tolerance?: number): number;
20
- declare export function isInteger(num: number, tolerance?: number): boolean;
21
- declare export function round(num: number, precision: number): number;
22
- declare export function roundTo(num: number, increment: number): number;
23
- declare export function floorTo(num: number, increment: number): number;
24
- declare export function ceilTo(num: number, increment: number): number;
25
-
26
- /**
27
- * toFraction
28
- *
29
- * Returns a [numerator, denominator] array rational representation
30
- * of `decimal`
31
- *
32
- * See http://en.wikipedia.org/wiki/Continued_fraction for implementation
33
- * details
34
- *
35
- * toFraction(4/8) => [1, 2]
36
- * toFraction(0.66) => [33, 50]
37
- * toFraction(0.66, 0.01) => [2/3]
38
- * toFraction(283 + 1/3) => [850, 3]
39
- */
40
- declare export function toFraction(
41
- decimal: number,
42
- tolerance?: number,
43
- maxDenominator?: number
44
- ): [number, number];
@@ -1,52 +0,0 @@
1
- /**
2
- * Flowtype definitions for data
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import * as kvector from "./vector";
8
- export type Point = $ReadOnlyArray<number>;
9
- declare export function rotateRad(
10
- point: Point,
11
- theta: number,
12
- center?: Point
13
- ): Point;
14
- declare export function rotateDeg(
15
- point: Point,
16
- theta: number,
17
- center?: Point
18
- ): Point;
19
- declare export function distanceToPoint(point1: Point, point2: Point): number;
20
- declare export function distanceToLine(
21
- point: Point,
22
- line: [Point, Point]
23
- ): number;
24
- declare export function reflectOverLine<P: Point>(point: P, line: [P, P]): P;
25
-
26
- /**
27
- * Compares two points, returning -1, 0, or 1, for use with
28
- * Array.prototype.sort
29
- *
30
- * Note: This technically doesn't satisfy the total-ordering
31
- * requirements of Array.prototype.sort unless equalityTolerance
32
- * is 0. In some cases very close points that compare within a
33
- * few equalityTolerances could appear in the wrong order.
34
- */
35
- declare export function compare(
36
- point1: Point,
37
- point2: Point,
38
- equalityTolerance?: number
39
- ): number;
40
- declare export var is: typeof kvector.is;
41
- declare export var addVector: typeof kvector.add;
42
- declare export var addVectors: typeof kvector.add;
43
- declare export var subtractVector: typeof kvector.subtract;
44
- declare export var equal: typeof kvector.equal;
45
- declare export var polarRadFromCart: typeof kvector.polarRadFromCart;
46
- declare export var polarDegFromCart: typeof kvector.polarDegFromCart;
47
- declare export var cartFromPolarRad: typeof kvector.cartFromPolarRad;
48
- declare export var cartFromPolarDeg: typeof kvector.cartFromPolarDeg;
49
- declare export var round: typeof kvector.round;
50
- declare export var roundTo: typeof kvector.roundTo;
51
- declare export var floorTo: typeof kvector.floorTo;
52
- declare export var ceilTo: typeof kvector.ceilTo;
package/dist/ray.js.flow DELETED
@@ -1,13 +0,0 @@
1
- /**
2
- * Flowtype definitions for data
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import type { Point } from "./point";
8
- export type Ray = [Point, Point];
9
- declare export function equal(
10
- ray1: Ray,
11
- ray2: Ray,
12
- tolerance?: number
13
- ): boolean;
@@ -1,74 +0,0 @@
1
- /**
2
- * Flowtype definitions for data
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- /**
8
- * Vector Utils
9
- * A vector is an array of numbers e.g. [0, 3, 4].
10
- */
11
- declare type Vector = $ReadOnlyArray<number>;
12
- /**
13
- * Checks if the given vector contains only numbers and, optionally, is of the
14
- * right dimension (length).
15
- *
16
- * is([1, 2, 3]) -> true
17
- * is([1, "Hello", 3]) -> false
18
- * is([1, 2, 3], 1) -> false
19
- */
20
- declare export function is<T>(
21
- vec: $ReadOnlyArray<T>,
22
- dimension?: number
23
- ): boolean;
24
- declare export function normalize<V: Vector>(v: V): V;
25
- declare export function length(v: Vector): number;
26
- declare export function dot(a: Vector, b: Vector): number;
27
- declare export function add<V: Vector>(...vecs: $ReadOnlyArray<V>): V;
28
- declare export function subtract<V: Vector>(v1: V, v2: V): V;
29
- declare export function negate<V: Vector>(v: V): V;
30
- declare export function scale<V: Vector>(v1: V, scalar: number): V;
31
- declare export function equal(
32
- v1: Vector,
33
- v2: Vector,
34
- tolerance?: number
35
- ): boolean;
36
- declare export function codirectional(
37
- v1: Vector,
38
- v2: Vector,
39
- tolerance?: number
40
- ): boolean;
41
- declare export function collinear(
42
- v1: Vector,
43
- v2: Vector,
44
- tolerance?: number
45
- ): boolean;
46
- declare export function polarRadFromCart(
47
- v: $ReadOnlyArray<number>
48
- ): $ReadOnlyArray<number>;
49
- declare export function polarDegFromCart(
50
- v: $ReadOnlyArray<number>
51
- ): $ReadOnlyArray<number>;
52
- declare export function cartFromPolarRad(
53
- radius: number,
54
- theta?: number
55
- ): $ReadOnlyArray<number>;
56
- declare export function cartFromPolarDeg(
57
- radius: number,
58
- theta?: number
59
- ): $ReadOnlyArray<number>;
60
- declare export function rotateRad(
61
- v: $ReadOnlyArray<number>,
62
- theta: number
63
- ): $ReadOnlyArray<number>;
64
- declare export function rotateDeg(
65
- v: $ReadOnlyArray<number>,
66
- theta: number
67
- ): $ReadOnlyArray<number>;
68
- declare export function angleRad(v1: Vector, v2: Vector): number;
69
- declare export function angleDeg(v1: Vector, v2: Vector): number;
70
- declare export function projection<V: Vector>(v1: V, v2: V): V;
71
- declare export function round<V: Vector>(vec: V, precision: V | number): V;
72
- declare export function roundTo<V: Vector>(vec: V, increment: V | number): V;
73
- declare export function floorTo<V: Vector>(vec: V, increment: V | number): V;
74
- declare export function ceilTo<V: Vector>(vec: V, increment: V | number): V;