-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
77 lines (73 loc) · 1.79 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* Distance function to the supershape, works in polar coordinates
*
* @param {number} theta Polar angle
* @param {number} m supershape parameter
* @param {number} exponent supershape exponent
* @returns Distance to the supershape and curvature
*/
export function supershape(
theta: number,
m: number,
exponent: number
): {
r: number;
curvature: number;
};
type vec2 = { x: number; y: number };
type vec3 = { x: number; y: number; z: number };
/**
* Return a function that evaluates the supershape for a group of
* three points.
*
* @param {vec2} a Point A
* @param {vec2} b Point B
* @param {vec2} c Point C
* @param {number} rounding shape rounding parameter
* @param {number} exponent supershape exponent
* @returns
*/
export function getShapeFunction(
a: vec2,
b: vec2,
c: vec2,
rounding: number,
exponent: number
): (t: number) => {
curve: vec2;
curvature: number;
radius: number;
getPoint: (radius: number) => vec2;
};
/**
* Returns a function that evaluates the supershape for a group of
* three three dimensional points.
* @param {vec3} a Point A
* @param {vec3} b Point B
* @param {vec3} c Point C
* @param {number} rounding shape rounding parameter
* @param {number} exponent supershape exponent
*/
export function getCubicShapeFunction(
a: vec3,
b: vec3,
c: vec3,
rounding: number,
exponent: number
): (
t: number,
u: number
) => {
curve: vec3;
curvature: number;
radius: number;
getPoint: (radius: number) => vec3;
};
// helpers
export function sub(a: vec2, b: vec2): vec2;
export function add(a: vec2, b: vec2): vec2;
export function mul(a: vec2, b: vec2): vec2;
export function dot(a: vec2, b: vec2): number;
export function length(a: vec2): number;
export function normalize(a: vec2): vec2;
export function cross(a: vec2, b: vec2): number;