Mercurial > code > home > repos > light9
annotate web/lib/sylvester.d.ts @ 2405:69ca2b2fc133
overcomplicated attempt at persisting the pane layout in the rdf graph
this was hard because we have to somehow wait for the graph to load before config'ing the panes
author | drewp@bigasterisk.com |
---|---|
date | Fri, 17 May 2024 16:58:26 -0700 |
parents | 4556eebe5d73 |
children |
rev | line source |
---|---|
2145
cc34e9b8bb97
workaround sylvester module errors from tsc
drewp@bigasterisk.com
parents:
2144
diff
changeset
|
1 // local fixes; the DefinitelyTyped one had "is not a module" errors |
cc34e9b8bb97
workaround sylvester module errors from tsc
drewp@bigasterisk.com
parents:
2144
diff
changeset
|
2 |
cc34e9b8bb97
workaround sylvester module errors from tsc
drewp@bigasterisk.com
parents:
2144
diff
changeset
|
3 |
2144 | 4 // Type definitions for sylvester 0.1.3 |
5 // Project: https://github.com/jcoglan/sylvester | |
6 // Definitions by: Stephane Alie <https://github.com/StephaneAlie> | |
7 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | |
8 | |
9 // === Sylvester === | |
10 // Vector and Matrix mathematics modules for JavaScript | |
11 // Copyright (c) 2007 James Coglan | |
12 | |
2145
cc34e9b8bb97
workaround sylvester module errors from tsc
drewp@bigasterisk.com
parents:
2144
diff
changeset
|
13 export declare module Sylvester { |
2144 | 14 interface VectorStatic { |
15 /** | |
16 * Constructor function. | |
17 */ | |
18 create(elements: Vector|Array<number>): Vector; | |
19 | |
20 i: Vector; | |
21 j: Vector; | |
22 k: Vector; | |
23 | |
24 /** | |
25 * Random vector of size n. | |
26 * | |
27 * @param {number} n The vector size. | |
28 */ | |
29 Random(n: number): Vector; | |
30 | |
31 /** | |
32 * Vector filled with zeros. | |
33 * | |
34 * @param {number} n The vector size. | |
35 */ | |
36 Zero(n: number): Vector; | |
37 } | |
38 interface MatrixStatic { | |
39 /** | |
40 * Constructor function. | |
41 * | |
42 * @param {Array<number>|Array<Array<number>>|Vector|Matrix} elements The elements. | |
43 */ | |
44 create(elements: Array<number>|Array<Array<number>>|Vector | Matrix): Matrix; | |
45 | |
46 /** | |
47 * Identity matrix of size n. | |
48 * | |
49 * @param {number} n The size. | |
50 */ | |
51 I(n: number): Matrix; | |
52 | |
53 /** | |
54 * Diagonal matrix - all off-diagonal elements are zero | |
55 * | |
56 * @param {any} elements The elements. | |
57 */ | |
58 Diagonal(elements: Array<number>|Array<Array<number>>|Vector | Matrix): Matrix; | |
59 | |
60 /** | |
61 * Rotation matrix about some axis. If no axis is supplied, assume we're after a 2D transform. | |
62 * | |
63 * @param {number} theta The angle in radians. | |
64 * @param {Vector} a [Optional] The axis. | |
65 */ | |
66 Rotation(theta: number, a?: Vector): Matrix; | |
67 | |
68 RotationX(t: number): Matrix; | |
69 RotationY(t: number): Matrix; | |
70 RotationZ(t: number): Matrix; | |
71 | |
72 /** | |
73 * Random matrix of n rows, m columns. | |
74 * | |
75 * @param {number} n The number of rows. | |
76 * @param {number} m The number of columns. | |
77 */ | |
78 Random(n: number, m: number): Matrix; | |
79 | |
80 /** | |
81 * Matrix filled with zeros. | |
82 * | |
83 * @param {number} n The number of rows. | |
84 * @param {number} m The number of columns. | |
85 */ | |
86 Zero(n: number, m: number): Matrix; | |
87 } | |
88 | |
89 interface LineStatic { | |
90 /** | |
91 * Constructor function. | |
92 * | |
93 * @param Array<number>|Vector anchor The anchor vector. | |
94 * @param Array<number>|Vector direction The direction vector. | |
95 */ | |
96 create(anchor: Array<number>|Vector, direction: Array<number>|Vector): Line; | |
97 | |
98 X: Line; | |
99 Y: Line; | |
100 Z: Line; | |
101 } | |
102 interface PlaneStatic { | |
103 /** | |
104 * Constructor function. | |
105 */ | |
106 create(anchor: Array<number>|Vector, normal: Array<number>|Vector): Plane; | |
107 | |
108 /** | |
109 * Constructor function. | |
110 */ | |
111 create(anchor: Array<number>|Vector, v1: Array<number>|Vector, v2: Array<number>|Vector): Plane; | |
112 | |
113 XY: Plane; | |
114 YZ: Plane; | |
115 ZX: Plane; | |
116 YX: Plane; | |
117 } | |
118 } | |
119 | |
120 interface Vector { | |
121 /** | |
122 * Gets an array containing the vector's elements. | |
123 */ | |
124 elements: Array<number>; | |
125 | |
126 /** | |
127 * Returns element i of the vector. | |
128 */ | |
129 e(i: number): number; | |
130 | |
131 /** | |
132 * Returns the number of elements the vector has. | |
133 */ | |
134 dimensions(): number; | |
135 | |
136 /** | |
137 * Returns the modulus ('length') of the vector. | |
138 */ | |
139 modulus(): number; | |
140 | |
141 /** | |
142 * Returns true if the vector is equal to the argument. | |
143 * | |
144 * @param {Vector|Array<number>} vector The vector to compare equality. | |
145 */ | |
146 eql(vector: Vector|Array<number>): boolean; | |
147 | |
148 /** | |
149 * Returns a copy of the vector. | |
150 */ | |
151 dup(): Vector; | |
152 | |
153 /** | |
154 * Maps the vector to another vector according to the given function. | |
155 * | |
156 * @param {Function} fn The function to apply to each element (x, i) => {}. | |
157 */ | |
158 map(fn: (x: number, i: number) => any): Vector; | |
159 | |
160 /** | |
161 * Calls the iterator for each element of the vector in turn. | |
162 * | |
163 * @param {Function} fn The function to apply to each element (x, i) => {}. | |
164 */ | |
165 each(fn: (x: number, i: number) => any): void; | |
166 | |
167 /** | |
168 * Returns a new vector created by normalizing the receiver. | |
169 */ | |
170 toUnitVector(): Vector; | |
171 | |
172 /** | |
173 * Returns the angle between the vector and the argument (also a vector). | |
174 * | |
175 * @param {Vector} vector The other vector to calculate the angle. | |
176 */ | |
177 angleFrom(vector: Vector): number; | |
178 | |
179 /** | |
180 * Returns true if the vector is parallel to the argument. | |
181 * | |
182 * @param {Vector} vector The other vector. | |
183 */ | |
184 isParallelTo(vector: Vector): boolean; | |
185 | |
186 /** | |
187 * Returns true if the vector is antiparallel to the argument. | |
188 * | |
189 * @param {Vector} vector The other vector. | |
190 */ | |
191 isAntiparallelTo(vector: Vector): boolean; | |
192 | |
193 /** | |
194 * Returns true iff the vector is perpendicular to the argument. | |
195 * | |
196 * @param {Vector} vector The other vector. | |
197 */ | |
198 isPerpendicularTo(vector: Vector): boolean; | |
199 | |
200 /** | |
201 * Returns the result of adding the argument to the vector. | |
202 * | |
203 * @param {Vector|Array<number>} vector The vector. | |
204 */ | |
205 add(vector: Vector|Array<number>): Vector; | |
206 | |
207 /** | |
208 * Returns the result of subtracting the argument from the vector. | |
209 * | |
210 * @param {Vector|Array<number>} vector The vector. | |
211 */ | |
212 subtract(vector: Vector|Array<number>): Vector; | |
213 | |
214 /** | |
215 * Returns the result of multiplying the elements of the vector by the argument. | |
216 * | |
217 * @param {number} k The value by which to multiply the vector. | |
218 */ | |
219 multiply(k: number): Vector; | |
220 | |
221 /** | |
222 * Returns the result of multiplying the elements of the vector by the argument (Alias for multiply(k)). | |
223 * | |
224 * @param {number} k The value by which to multiply the vector. | |
225 */ | |
226 x(k: number): Vector; | |
227 | |
228 /** | |
229 * Returns the scalar product of the vector with the argument. Both vectors must have equal dimensionality. | |
230 * | |
231 * @param: {Vector|Array<number>} vector The other vector. | |
232 */ | |
233 dot(vector: Vector|Array<number>): number; | |
234 | |
235 /** | |
236 * Returns the vector product of the vector with the argument. Both vectors must have dimensionality 3. | |
237 * | |
238 * @param {Vector|Array<number>} vector The other vector. | |
239 */ | |
240 cross(vector: Vector|Array<number>): Vector; | |
241 | |
242 /** | |
243 * Returns the (absolute) largest element of the vector. | |
244 */ | |
245 max(): number; | |
246 | |
247 /** | |
248 * Returns the index of the first match found. | |
249 * | |
250 * @param {number} x The value. | |
251 */ | |
252 indexOf(x: number): number; | |
253 | |
254 /** | |
255 * Returns a diagonal matrix with the vector's elements as its diagonal elements. | |
256 */ | |
257 toDiagonalMatrix(): Matrix; | |
258 | |
259 /** | |
260 * Returns the result of rounding the elements of the vector. | |
261 */ | |
262 round(): Vector; | |
263 | |
264 /** | |
265 * Returns a copy of the vector with elements set to the given value if they differ from | |
266 * it by less than Sylvester.precision. | |
267 * | |
268 * @param {number} x The value to snap to. | |
269 */ | |
270 snapTo(x: number): Vector; | |
271 | |
272 /** | |
273 * Returns the vector's distance from the argument, when considered as a point in space. | |
274 * | |
275 * @param {Vector|Line|Plane} obj The object to calculate the distance. | |
276 */ | |
277 distanceFrom(obj: Vector|Line|Plane): number; | |
278 | |
279 /** | |
280 * Returns true if the vector is point on the given line. | |
281 * | |
282 * @param {Line} line The line. | |
283 */ | |
284 liesOn(line: Line): boolean; | |
285 | |
286 /** | |
287 * Return true if the vector is a point in the given plane. | |
288 * | |
289 * @param {Plane} plane The plane. | |
290 */ | |
291 liesIn(plane: Plane): boolean; | |
292 | |
293 /** | |
294 * Rotates the vector about the given object. The object should be a point if the vector is 2D, | |
295 * and a line if it is 3D. Be careful with line directions! | |
296 * | |
297 * @param {number|Matrix} t The angle in radians or in rotation matrix. | |
298 * @param {Vector|Line} obj The rotation axis. | |
299 */ | |
300 rotate(t: number|Matrix, obj: Vector|Line): Vector; | |
301 | |
302 /** | |
303 * Returns the result of reflecting the point in the given point, line or plane. | |
304 * | |
305 * @param {Vector|Line|Plane} obj The object. | |
306 */ | |
307 reflectionIn(obj: Vector|Line|Plane): Vector; | |
308 | |
309 /** | |
310 * Utility to make sure vectors are 3D. If they are 2D, a zero z-component is added. | |
311 */ | |
312 to3D(): Vector; | |
313 | |
314 /** | |
315 * Returns a string representation of the vector. | |
316 */ | |
317 inspect(): string; | |
318 | |
319 /** | |
320 * Set vector's elements from an array. | |
321 * | |
322 * @param {Vector|Array<number>} els The elements. | |
323 */ | |
324 setElements(els: Vector|Array<number>): Vector; | |
325 } | |
326 | |
327 interface Matrix { | |
328 /** | |
329 * Gets a nested array containing the matrix's elements. | |
330 */ | |
331 elements: Array<Array<number>>; | |
332 /** | |
333 * Returns element (i,j) of the matrix. | |
334 * | |
335 * @param {number} i The row index. | |
336 * @param {number} j The column index. | |
337 */ | |
338 e(i: number, j: number): any; | |
339 | |
340 /** | |
341 * Returns row k of the matrix as a vector. | |
342 * | |
343 * @param {number} i The row index. | |
344 */ | |
345 row(i: number): Vector; | |
346 | |
347 /** | |
348 * Returns column k of the matrix as a vector. | |
349 * | |
350 * @param {number} j The column index. | |
351 */ | |
352 col(j: number): Vector; | |
353 | |
354 /** | |
355 * Returns the number of rows/columns the matrix has. | |
356 * | |
357 * @return {any} An object { rows: , cols: }. | |
358 */ | |
359 dimensions(): any; | |
360 | |
361 /** | |
362 * Returns the number of rows in the matrix. | |
363 */ | |
364 rows(): number; | |
365 | |
366 /** | |
367 * Returns the number of columns in the matrix. | |
368 */ | |
369 cols(): number; | |
370 | |
371 /** | |
372 * Returns true if the matrix is equal to the argument. You can supply a vector as the argument, | |
373 * in which case the receiver must be a one-column matrix equal to the vector. | |
374 * | |
375 * @param {Vector|Matrix} matrix The argument to compare. | |
376 */ | |
377 eql(matrix: Vector|Matrix): boolean; | |
378 | |
379 /** | |
380 * Returns a copy of the matrix. | |
381 */ | |
382 dup(): Matrix; | |
383 | |
384 /** | |
385 * Maps the matrix to another matrix (of the same dimensions) according to the given function. | |
386 * | |
387 * @param {Function} fn The function. | |
388 */ | |
389 map(fn: (x: number, i: number, j: number) => any): Matrix; | |
390 | |
391 /** | |
392 * Returns true iff the argument has the same dimensions as the matrix. | |
393 * | |
394 * @param {Matrix} matrix The other matrix. | |
395 */ | |
396 isSameSizeAs(matrix: Matrix): boolean; | |
397 | |
398 /** | |
399 * Returns the result of adding the argument to the matrix. | |
400 * | |
401 * @param {Matrix} matrix The matrix to add. | |
402 */ | |
403 add(matrix: Matrix): Matrix; | |
404 | |
405 /** | |
406 * Returns the result of subtracting the argument from the matrix. | |
407 * | |
408 * @param {Matrix} matrix The matrix to substract. | |
409 */ | |
410 subtract(matrix: Matrix): Matrix; | |
411 | |
412 /** | |
413 * Returns true iff the matrix can multiply the argument from the left. | |
414 * | |
415 * @param {Matrix} matrix The matrix. | |
416 */ | |
417 canMultiplyFromLeft(matrix: Matrix): boolean; | |
418 | |
419 /** | |
420 * Returns the result of multiplying the matrix from the right by the argument. If the argument is a scalar | |
421 * then just multiply all the elements. If the argument is a vector, a vector is returned, which saves you | |
422 * having to remember calling col(1) on the result. | |
423 * | |
424 * @param {number|Matrix} matrix The multiplier. | |
425 */ | |
426 multiply(matrix: number|Matrix): Matrix; | |
427 | |
428 /** | |
429 * Returns the result of multiplying the matrix from the right by the argument. If the argument is a scalar | |
430 * then just multiply all the elements. If the argument is a vector, a vector is returned, which saves you | |
431 * having to remember calling col(1) on the result. | |
432 * | |
433 * @param {Vector} vector The multiplier. | |
434 */ | |
435 multiply(vector: Vector): Vector; | |
436 | |
437 x(matrix: number|Matrix): Matrix; | |
438 | |
439 x(vector: Vector): Vector; | |
440 | |
441 /** | |
442 * Returns a submatrix taken from the matrix. Argument order is: start row, start col, nrows, ncols. | |
443 * Element selection wraps if the required index is outside the matrix's bounds, so you could use | |
444 * this to perform row/column cycling or copy-augmenting. | |
445 * | |
446 * @param {number} a Starting row index. | |
447 * @param {number} b Starting column index. | |
448 * @param {number} c Number of rows. | |
449 * @param {number} d Number of columns. | |
450 */ | |
451 minor(a: number, b: number, c: number, d: number): Matrix; | |
452 | |
453 /** | |
454 * Returns the transpose of the matrix. | |
455 */ | |
456 transpose(): Matrix; | |
457 | |
458 /** | |
459 * Returns true if the matrix is square. | |
460 */ | |
461 isSquare(): boolean; | |
462 | |
463 /** | |
464 * Returns the (absolute) largest element of the matrix. | |
465 */ | |
466 max(): number; | |
467 | |
468 /** | |
469 * Returns the indeces of the first match found by reading row-by-row from left to right. | |
470 * | |
471 * @param {number} x The value. | |
472 * | |
473 * @return {any} The element indeces i.e: { row:1, col:1 } | |
474 */ | |
475 indexOf(x: number): any; | |
476 | |
477 /** | |
478 * If the matrix is square, returns the diagonal elements as a vector; otherwise, returns null. | |
479 */ | |
480 diagonal(): Vector; | |
481 | |
482 /** | |
483 * Make the matrix upper (right) triangular by Gaussian elimination. This method only adds multiples | |
484 * of rows to other rows. No rows are scaled up or switched, and the determinant is preserved. | |
485 */ | |
486 toRightTriangular(): Matrix; | |
487 toUpperTriangular(): Matrix; | |
488 | |
489 /** | |
490 * Returns the determinant for square matrices. | |
491 */ | |
492 determinant(): number; | |
493 det(): number; | |
494 | |
495 /** | |
496 * Returns true if the matrix is singular. | |
497 */ | |
498 isSingular(): boolean; | |
499 | |
500 /** | |
501 * Returns the trace for square matrices. | |
502 */ | |
503 trace(): number; | |
504 tr(): number; | |
505 | |
506 /** | |
507 * Returns the rank of the matrix. | |
508 */ | |
509 rank(): number; | |
510 rk(): number; | |
511 | |
512 /** | |
513 * Returns the result of attaching the given argument to the right-hand side of the matrix. | |
514 * | |
515 * @param {Matrix|Vector} matrix The matrix or vector. | |
516 */ | |
517 augment(matrix: Matrix|Vector): Matrix; | |
518 | |
519 /** | |
520 * Returns the inverse (if one exists) using Gauss-Jordan. | |
521 */ | |
522 inverse(): Matrix; | |
523 inv(): Matrix; | |
524 | |
525 /** | |
526 * Returns the result of rounding all the elements. | |
527 */ | |
528 round(): Matrix; | |
529 | |
530 /** | |
531 * Returns a copy of the matrix with elements set to the given value if they differ from it | |
532 * by less than Sylvester.precision. | |
533 * | |
534 * @param {number} x The value. | |
535 */ | |
536 snapTo(x: number): Matrix; | |
537 | |
538 /** | |
539 * Returns a string representation of the matrix. | |
540 */ | |
541 inspect(): string; | |
542 | |
543 /** | |
544 * Set the matrix's elements from an array. If the argument passed is a vector, the resulting matrix | |
545 * will be a single column. | |
546 * | |
547 * @param {Array<number>|Array<Array<number>>|Vector|Matrix} matrix The elements. | |
548 */ | |
549 setElements(matrix: Array<number>|Array<Array<number>>|Vector|Matrix): Matrix; | |
550 } | |
551 | |
552 interface Line { | |
553 /** | |
554 * Gets the 3D vector corresponding to a point on the line. | |
555 */ | |
556 anchor: Vector; | |
557 | |
558 /** | |
559 * Gets a normalized 3D vector representing the line's direction. | |
560 */ | |
561 direction: Vector; | |
562 | |
563 /** | |
564 * Returns true if the argument occupies the same space as the line. | |
565 * | |
566 * @param {Line} line The other line. | |
567 */ | |
568 eql(line: Line): boolean; | |
569 | |
570 /** | |
571 * Returns a copy of the line. | |
572 */ | |
573 dup(): Line; | |
574 | |
575 /** | |
576 * Returns the result of translating the line by the given vector/array. | |
577 * | |
578 * @param {Vector|Array<number>} vector The translation vector. | |
579 */ | |
580 translate(vector: Vector|Array<number>): Line; | |
581 | |
582 /** | |
583 * Returns true if the line is parallel to the argument. Here, 'parallel to' means that the argument's | |
584 * direction is either parallel or antiparallel to the line's own direction. A line is parallel to a | |
585 * plane if the two do not have a unique intersection. | |
586 * | |
587 * @param {Line|Plane} obj The object. | |
588 */ | |
589 isParallelTo(obj: Line|Plane): boolean; | |
590 | |
591 /** | |
592 * Returns the line's perpendicular distance from the argument, which can be a point, a line or a plane. | |
593 * | |
594 * @param {Vector|Line|Plane} obj The object. | |
595 */ | |
596 distanceFrom(obj: Vector|Line|Plane): number; | |
597 | |
598 /** | |
599 * Returns true if the argument is a point on the line. | |
600 * | |
601 * @param {Vector} point The point. | |
602 */ | |
603 contains(point: Vector): boolean; | |
604 | |
605 /** | |
606 * Returns true if the line lies in the given plane. | |
607 * | |
608 * @param {Plane} plane The plane. | |
609 */ | |
610 liesIn(plane: Plane): boolean; | |
611 | |
612 /** | |
613 * Returns true if the line has a unique point of intersection with the argument. | |
614 * | |
615 * @param {Line|Plane} obj The object. | |
616 */ | |
617 intersects(obj: Line|Plane): boolean; | |
618 | |
619 /** | |
620 * Returns the unique intersection point with the argument, if one exists. | |
621 * | |
622 * @param {Line|Plane} obj The object. | |
623 */ | |
624 intersectionWith(obj: Line|Plane): Vector; | |
625 | |
626 /** | |
627 * Returns the point on the line that is closest to the given point or line. | |
628 * | |
629 * @param {Vector|Line} obj The object. | |
630 */ | |
631 pointClosestTo(obj: Vector|Line): Vector; | |
632 | |
633 /** | |
634 * Returns a copy of the line rotated by t radians about the given line. Works by finding the argument's | |
635 * closest point to this line's anchor point (call this C) and rotating the anchor about C. Also rotates | |
636 * the line's direction about the argument's. Be careful with this - the rotation axis' direction | |
637 * affects the outcome! | |
638 * | |
639 * @param {number} t The angle in radians. | |
640 * @param {Vector|Line} axis The axis. | |
641 */ | |
642 rotate(t: number, axis: Vector|Line): Line; | |
643 | |
644 /** | |
645 * Returns the line's reflection in the given point or line. | |
646 * | |
647 * @param {Vector|Line|Plane} obj The object. | |
648 */ | |
649 reflectionIn(obj: Vector|Line|Plane): Line; | |
650 | |
651 /** | |
652 * Set the line's anchor point and direction. | |
653 * | |
654 * @param {Array<number>|Vector} anchor The anchor vector. | |
655 * @param {Array<number>|Vector} direction The direction vector. | |
656 */ | |
657 setVectors(anchor: Array<number>|Vector, direction: Array<number>|Vector): Line; | |
658 } | |
659 | |
660 interface Plane { | |
661 /** | |
662 * Gets the 3D vector corresponding to a point in the plane. | |
663 */ | |
664 anchor: Vector; | |
665 | |
666 /** | |
667 * Gets a normalized 3D vector perpendicular to the plane. | |
668 */ | |
669 normal: Vector; | |
670 | |
671 /** | |
672 * Returns true if the plane occupies the same space as the argument. | |
673 * | |
674 * @param {Plane} plane The other plane. | |
675 */ | |
676 eql(plane: Plane): boolean; | |
677 | |
678 /** | |
679 * Returns a copy of the plane. | |
680 */ | |
681 dup(): Plane; | |
682 | |
683 /** | |
684 * Returns the result of translating the plane by the given vector. | |
685 * | |
686 * @param {Array<number>|Vector} vector The translation vector. | |
687 */ | |
688 translate(vector: Array<number>|Vector): Plane; | |
689 | |
690 /** | |
691 * Returns true if the plane is parallel to the argument. Will return true if the planes are equal, | |
692 * or if you give a line and it lies in the plane. | |
693 * | |
694 * @param {Line|Plane} obj The object. | |
695 */ | |
696 isParallelTo(obj: Line|Plane): boolean; | |
697 | |
698 /** | |
699 * Returns true if the receiver is perpendicular to the argument. | |
700 * | |
701 * @param {Plane} plane The other plane. | |
702 */ | |
703 isPerpendicularTo(plane: Plane): boolean; | |
704 | |
705 /** | |
706 * Returns the plane's distance from the given object (point, line or plane). | |
707 * | |
708 * @parm {Vector|Line|Plane} obj The object. | |
709 */ | |
710 distanceFrom(obj: Vector|Line|Plane): number; | |
711 | |
712 /** | |
713 * Returns true if the plane contains the given point or line. | |
714 * | |
715 * @param {Vector|Line} obj The object. | |
716 */ | |
717 contains(obj: Vector|Line): boolean; | |
718 | |
719 /** | |
720 * Returns true if the plane has a unique point/line of intersection with the argument. | |
721 * | |
722 * @param {Line|Plane} obj The object. | |
723 */ | |
724 intersects(obj: Line|Plane): boolean; | |
725 | |
726 /** | |
727 * Returns the unique intersection with the argument, if one exists. | |
728 * | |
729 * @param {Line} line The line. | |
730 */ | |
731 intersectionWith(line: Line): Vector; | |
732 | |
733 /** | |
734 * Returns the unique intersection with the argument, if one exists. | |
735 * | |
736 * @param {Plane} plane The plane. | |
737 */ | |
738 intersectionWith(plane: Plane): Line; | |
739 | |
740 /** | |
741 * Returns the point in the plane closest to the given point. | |
742 * | |
743 * @param {Vector} point The point. | |
744 */ | |
745 pointClosestTo(point: Vector): Vector; | |
746 | |
747 /** | |
748 * Returns a copy of the plane, rotated by t radians about the given line. See notes on Line#rotate. | |
749 * | |
750 * @param {number} t The angle in radians. | |
751 * @param {Line} axis The line axis. | |
752 */ | |
753 rotate(t: number, axis: Line): Plane; | |
754 | |
755 /** | |
756 * Returns the reflection of the plane in the given point, line or plane. | |
757 * | |
758 * @param {Vector|Line|Plane} obj The object. | |
759 */ | |
760 reflectionIn(obj: Vector|Line|Plane): Plane; | |
761 | |
762 /** | |
763 * Sets the anchor point and normal to the plane. Normal vector is normalised before storage. | |
764 * | |
765 * @param {Array<number>|Vector} anchor The anchor vector. | |
766 * @param {Array<number>|Vector} normal The normal vector. | |
767 */ | |
768 setVectors(anchor: Array<number>|Vector, normal: Array<number>|Vector): Plane; | |
769 | |
770 /** | |
771 * Sets the anchor point and normal to the plane. The normal is calculated by assuming the three points | |
772 * should lie in the same plane. Normal vector is normalised before storage. | |
773 * | |
774 * @param {Array<number>|Vector} anchor The anchor vector. | |
775 * @param {Array<number>|Vector} v1 The first direction vector. | |
776 * @param {Array<number>|Vector} v2 The second direction vector. | |
777 */ | |
778 setVectors(anchor: Array<number>|Vector, v1: Array<number>|Vector, v2: Array<number>|Vector): Plane; | |
779 } | |
780 | |
781 declare module Sylvester { | |
782 export var version: string; | |
783 export var precision: number; | |
784 } | |
785 | |
786 declare var Vector: Sylvester.VectorStatic; | |
787 declare var Matrix: Sylvester.MatrixStatic; | |
788 declare var Line: Sylvester.LineStatic; | |
789 declare var Plane: Sylvester.PlaneStatic; | |
790 | |
791 /** | |
792 * Constructor function. | |
793 * | |
794 * @param {Vector|Array<number} elements The elements. | |
795 */ | |
796 declare function $V(elements: Vector|Array<number>): Vector; | |
797 | |
798 /** | |
799 * Constructor function. | |
800 * | |
801 * @param {Array<number>|Array<Array<number>>|Vector|Matrix} elements The elements. | |
802 */ | |
803 declare function $M(elements: Array<number>|Array<Array<number>>|Vector | Matrix): Matrix; | |
804 | |
805 /** | |
806 * Constructor function. | |
807 * | |
808 * @param Array<number>|Vector anchor The anchor vector. | |
809 * @param Array<number>|Vector direction The direction vector. | |
810 */ | |
811 declare function $L(anchor: Array<number>|Vector, direction: Array<number>|Vector): Line; | |
812 | |
813 /** | |
814 * Constructor function. | |
815 * | |
816 * @param {Array<number>|Vector} anchor The anchor vector. | |
817 * @param {Array<number>|Vector} normal The normal vector. | |
818 */ | |
819 declare function $P(anchor: Array<number>|Vector, normal: Array<number>|Vector): Plane; | |
820 | |
821 /** | |
822 * Constructor function. | |
823 * | |
824 * @param {Array<number>|Vector} anchor The anchor vector. | |
825 * @param {Array<number>|Vector} v1 The first direction vector. | |
826 * @param {Array<number>|Vecotr} v2 The second direction vector. | |
827 */ | |
828 declare function $P(anchor: Array<number>|Vector, v1: Array<number>|Vector, v2: Array<number>|Vector): Plane; |