-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
165 lines (165 loc) · 4.84 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
export declare enum CoordinateType {
CARTESIAN_2D = 'CARTESIAN_2D',
CARTESIAN_3D = 'CARTESIAN_3D',
CYLINDRICAL = 'CYLINDRICAL',
POLAR = 'POLAR',
SPHERICAL = 'SPHERICAL'
}
export declare type DoubleNumArray = [number, number]
export declare type TripleNumArray = [number, number, number]
export declare type Cartesian2dCoordinateTuple = DoubleNumArray
export declare type Cartesian3dCoordinateTuple = TripleNumArray
export declare type CartesianTuple =
| Cartesian2dCoordinateTuple
| Cartesian3dCoordinateTuple
export declare type CylindricalCoordinateTuple = TripleNumArray
export declare type PolarCoordinateTuple = DoubleNumArray
export declare type SphericalCoordinateTuple = TripleNumArray
export declare type CoordinateTuple =
| Cartesian2dCoordinateTuple
| Cartesian3dCoordinateTuple
| CylindricalCoordinateTuple
| PolarCoordinateTuple
| SphericalCoordinateTuple
/**
* @constructor Coordinate
* @description Defines object which can convert between coordinate systems.
* It is recommended to use one of the Coodinate.STATIC_CONSTRUCTOR functions
* to generate your first coordinate before conversions. e.g. Coodinate.spherical(...)
* @param {Object} config
* {
* label: 'type of initial coordinate',
* coords: {
* x/y/z/r/t/p: 'k-v pairs'
* },
* isDegree: Boolean
* }
*/
export declare class Coordinate {
isRadian: boolean
isDegree: boolean
type: CoordinateType
coordinates: CoordinateTuple
private cooridnatesByType
/**
* Create a point provided x, y, and optionally z coordinates
* @param {Object} coordinates
* @return {Coordinate}
*/
static cartesian (coordinates: CartesianTuple): Coordinate
static cylindrical (coordinates: CylindricalCoordinateTuple): Coordinate
static polar (coordinates: PolarCoordinateTuple): Coordinate
static spherical (coordinates: SphericalCoordinateTuple): Coordinate
/**
* Convert a cylindrical to a spherical coordinates
* @param {Array} rtz
* @param {Boolean} isDegree
* @return {Array} [radius, theta, phi]
*/
static cylindricalToSpherical ({
coordinate,
isDegree
}: {
coordinate: CylindricalCoordinateTuple
isDegree: boolean
}): TripleNumArray
/**
* Convert polar to 2d cartesian coordinates
* @param {Array} rt [radis, theta]
* @param {Boolean} isDegree specifies units
* @return {Array} [x, y]
*/
static polarToCart2d ({
coordinate,
isDegree
}: {
coordinate: PolarCoordinateTuple
isDegree?: boolean
}): [number, number]
/**
* Convert 3d cartesian to 3d cylindrical coordinates
* @param {Array} argument [x, y, z] coords
* @param {Boolean=} isDegree overrides default radian theta assumption
* @param {Array=} center [x, y] coords of center of circle
* @return {Array} [radius, theta, z]
*/
static cartesian3dToCylindrical ({
coordinate,
isDegree,
center
}: {
coordinate: TripleNumArray
isDegree?: boolean
center?: TripleNumArray
}): TripleNumArray
static sphericalToCart3d ({
coordinate,
isDegree
}: {
coordinate: SphericalCoordinateTuple
isDegree?: boolean
}): [number, number, number]
/**
* Convert spherical to cylindrical coordinates
*/
static sphericalToCylindrical ({
coordinate,
isDegree
}: {
coordinate: SphericalCoordinateTuple
isDegree?: boolean
}): TripleNumArray
/**
* Convert 3d cartesian to 3d spherical coordinates
* @param {Array} argument [x, y, z] coords
* @param {Boolean=} isDegree overrides default radian theta assumption
* @param {Array=} center [x, y, z] coords of center of circle
* @return {Array} [radius, theta, phi]
*/
static cartesian3dToSpherical ({
coordinate,
isDegree,
center
}: {
coordinate: Cartesian3dCoordinateTuple
isDegree?: boolean
center?: TripleNumArray
}): TripleNumArray
/**
* Convert cartesian 2d to polar coordinates
* @param {Array=} center [x, y] coords of center of circle. Defaults to [0, 0],
* however may be offset.
* @return {Array} [radius, theta]
*/
static cartesian2dToPolar ({
coordinate,
isDegree,
center
}: {
coordinate: CartesianTuple
isDegree?: boolean
center?: CartesianTuple
}): DoubleNumArray
constructor ({
coordinates,
isDegree,
isRadian,
type
}: {
coordinates?: CoordinateTuple
isDegree?: boolean
isRadian?: boolean
type: CoordinateType
})
cartesian (): CartesianTuple
cylindrical (options?: {
center?: DoubleNumArray | TripleNumArray
}): CylindricalCoordinateTuple
polar (options?: { center?: DoubleNumArray }): PolarCoordinateTuple
/**
* Converts current coordinate to spherical
* @param {Object} options
* @return {Array} coordinates in respective coordinate format
*/
spherical (options?: { center?: TripleNumArray }): SphericalCoordinateTuple
}