-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathquaternion.d.ts
140 lines (118 loc) · 5.53 KB
/
quaternion.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
type Matrix4_2D = [
[number, number, number, number],
[number, number, number, number],
[number, number, number, number],
[number, number, number, number],
];
type Matrix4 = [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
];
type Matrix3_2D = [[number, number, number], [number, number, number], [number, number, number]];
type Matrix3 = [number, number, number, number, number, number, number, number, number];
type QuaternionRecord = { w?: number; x?: number; y?: number; z?: number } & (
| { w: number }
| { x: number }
| { y: number }
| { z: number }
);
interface QuaternionComplexRecord {
re: number;
im: number;
}
type QuaternionArray = [number, number, number, number];
type QuaternionAugmentedArray = [number, number, number];
type AnyQuaternionArray = QuaternionArray | QuaternionAugmentedArray;
export class Quaternion {
constructor(w?: number, x?: number, y?: number, z?: number);
constructor(quaternion: string | AnyQuaternionArray | QuaternionRecord);
// tslint:disable-next-line:unified-signatures Avoid union of QuaternionRecord and QuaternionComplexRecord fields
constructor(quaternion: QuaternionComplexRecord);
w: number;
x: number;
y: number;
z: number;
add(w: number, x?: number, y?: number, z?: number): Quaternion;
add(quaternion: string | AnyQuaternionArray | QuaternionRecord): Quaternion;
// tslint:disable-next-line:unified-signatures Avoid union of QuaternionRecord and QuaternionComplexRecord fields
add(quaternion: QuaternionComplexRecord): Quaternion;
sub(w: number, x?: number, y?: number, z?: number): Quaternion;
sub(quaternion: string | AnyQuaternionArray | QuaternionRecord): Quaternion;
// tslint:disable-next-line:unified-signatures Avoid union of QuaternionRecord and QuaternionComplexRecord fields
sub(quaternion: QuaternionComplexRecord): Quaternion;
neg: () => Quaternion;
norm: () => number;
normSq: () => number;
normalize: () => Quaternion;
mul(w: number, x?: number, y?: number, z?: number): Quaternion;
mul(quaternion: string | AnyQuaternionArray | QuaternionRecord): Quaternion;
// tslint:disable-next-line:unified-signatures Avoid union of QuaternionRecord and QuaternionComplexRecord fields
mul(quaternion: QuaternionComplexRecord): Quaternion;
scale: (s: number) => Quaternion;
dot(w: number, x?: number, y?: number, z?: number): number;
dot(quaternion: string | AnyQuaternionArray | QuaternionRecord): number;
// tslint:disable-next-line:unified-signatures Avoid union of QuaternionRecord and QuaternionComplexRecord fields
dot(quaternion: QuaternionComplexRecord): number;
inverse: () => Quaternion;
div(w: number, x?: number, y?: number, z?: number): Quaternion;
div(quaternion: string | AnyQuaternionArray | QuaternionRecord): Quaternion;
// tslint:disable-next-line:unified-signatures Avoid union of QuaternionRecord and QuaternionComplexRecord fields
div(quaternion: QuaternionComplexRecord): Quaternion;
conjugate: () => Quaternion;
exp: () => Quaternion;
log: () => Quaternion;
pow(w: number, x?: number, y?: number, z?: number): Quaternion;
pow(quaternion: string | AnyQuaternionArray | QuaternionRecord): Quaternion;
// tslint:disable-next-line:unified-signatures Avoid union of QuaternionRecord and QuaternionComplexRecord fields
pow(quaternion: QuaternionComplexRecord): Quaternion;
equals(w: number, x?: number, y?: number, z?: number): boolean;
equals(quaternion: string | AnyQuaternionArray | QuaternionRecord): boolean;
// tslint:disable-next-line:unified-signatures Avoid union of QuaternionRecord and QuaternionComplexRecord fields
equals(quaternion: QuaternionComplexRecord): boolean;
isFinite: () => boolean;
isNaN: () => boolean;
toString: () => string;
real: () => number;
imag: () => [number, number, number];
toVector: () => [number, number, number, number];
toMatrix: <T extends boolean>(twoD: T) => T extends true ? Matrix3_2D : Matrix3;
toMatrix4: <T extends boolean>(twoD: T) => T extends true ? Matrix4_2D : Matrix4;
toCSSTransform: () => string;
toEuler: (order?: string) => [number, number, number];
toAxisAngle: () => [[number, number, number], number];
clone: () => Quaternion;
rotateVector: (v: [number, number, number]) => [number, number, number];
slerp(w: number, x?: number, y?: number, z?: number): (pct: number) => Quaternion;
slerp(quaternion: string | AnyQuaternionArray | QuaternionRecord): (pct: number) => Quaternion;
// tslint:disable-next-line:unified-signatures Avoid union of QuaternionRecord and QuaternionComplexRecord fields
slerp(quaternion: QuaternionComplexRecord): (pct: number) => Quaternion;
}
declare namespace Quaternion {
const Quaternion: Quaternion;
const ZERO: Quaternion;
const ONE: Quaternion;
const I: Quaternion;
const J: Quaternion;
const K: Quaternion;
function fromAxisAngle(axis: [number, number, number], angle: number): Quaternion;
function fromVectors(u: [number, number, number], v: [number, number, number]): Quaternion;
function random(): Quaternion;
function fromEuler(phi: number, theta: number, psi: number, order?: string): Quaternion;
function fromEulerLogical(psi: number, theta: number, phi: number, order?: string): Quaternion;
function fromMatrix(matrix: Matrix3 | Matrix3_2D): Quaternion;
}
export default Quaternion;