@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
216 lines • 6.36 kB
TypeScript
export class Subspan {
/**
*
* @param {number} dim dimension count
* @param {PointSet} s
* @param {number} k
*/
constructor(dim: number, s: PointSet, k: number);
/**
* @type {PointSet}
*/
S: PointSet;
/**
* reserve bit-field size
* @type {BitSet}
*/
membership: BitSet;
/**
*
* @type {number}
*/
dim: number;
/**
*
* @type {Int32Array}
*/
members: Int32Array;
/**
* DxD square matrix, where D is number of dimensions
* @type {number[][]}
*/
Q: number[][];
/**
* DxD square matrix, where D is number of dimensions
* @type {number[][]}
*/
R: number[][];
/**
* D sized vector
* @type {number[]}
*/
u: number[];
/**
* D sized vector
* @type {number[]}
*/
w: number[];
r: number;
/**
* Givens C coefficient
* @type {number}
*/
c: number;
/**
* Givens S coefficient
* @type {number}
*/
s: number;
dimension(): number;
/**
* The size of the instance's set <i>M</i>, a number between 0 and `dim+1`.
*
* Complexity: O(1).
*
* @returns {int} <i>|M|</i>
*/
size(): int;
/**
* Whether <i>S[i]</i> is a member of <i>M</i>.
*
* Complexity: O(1)
*
* @param {int} i
* the "global" index into <i>S</i>
* @returns {boolean} true iff <i>S[i]</i> is a member of <i>M</i>
*/
isMember(i: int): boolean;
/**
* The global index (into <i>S</i>) of an arbitrary element of <i>M</i>.
*
* Precondition: `size()>0`
*
* Postcondition: `isMember(anyMember())`
* @returns {number}
*/
anyMember(): number;
/**
* The index (into <i>S</i>) of the <i>i</i>th point in <i>M</i>. The points in <i>M</i> are
* internally ordered (in an arbitrary way) and this order only changes when {@link add()} or
* {@link remove()} is called.
*
* Complexity: O(1)
*
* @param {number} i
* the "local" index, 0 ≤ i < `size()`
* @return {number} <i>j</i> such that <i>S[j]</i> equals the <i>i</i>th point of M
*/
globalIndex(i: number): number;
/**
* Short-hand for code readability to access element <i>(i,j)</i> of a matrix that is stored in a
* one-dimensional array.
*
* @param {number} i
* zero-based row number
* @param {number} j
* zero-based column number
* @return {number} the index into the one-dimensional array to get the element at position <i>(i,j)</i> in
* the matrix
* @private
*/
private ind;
/**
* The point `members[r]` is called the <i>origin</i>.
*
* @return {number} index into <i>S</i> of the origin.
* @private
*/
private origin;
/**
* Determine the Givens coefficients <i>(c,s)</i> satisfying
*
* <pre>
* c * a + s * b = +/- (a^2 + b^2) c * b - s * a = 0
* </pre>
*
* We don't care about the signs here, for efficiency, so make sure not to rely on them anywhere.
*
* <i>Source:</i> "Matrix Computations" (2nd edition) by Gene H. B. Golub & Charles F. B. Van Loan
* (Johns Hopkins University Press, 1989), p. 216.
*
* Note that the code of this class sometimes does not call this method but only mentions it in a
* comment. The reason for this is performance; Java does not allow an efficient way of returning
* a pair of doubles, so we sometimes manually "inline" `givens()` for the sake of
* performance.
* @param {number} a
* @param {number} b
* @private
*/
private givens;
/**
* Appends the new column <i>u</i> (which is a member field of this instance) to the right of <i>A
* = QR</i>, updating <i>Q</i> and <i>R</i>. It assumes <i>r</i> to still be the old value, i.e.,
* the index of the column used now for insertion; <i>r</i> is not altered by this routine and
* should be changed by the caller afterwards.
*
* Precondition: `r<dim`
* @private
*/
private appendColumn;
/**
* Adds the point <i>S[index]</i> to the instance's set <i>M</i>.
*
* Precondition: `!isMember(index)`
*
* Complexity: O(dim^2).
*
* @param {number} index index into <i>S</i> of the point to add
*/
add(index: number): void;
/**
* Computes the vector <i>w</i> directed from point <i>p</i> to <i>v</i>, where <i>v</i> is the
* point in <i>aff(M)</i> that lies nearest to <i>p</i>.
*
* Precondition: `size()>0`
*
* Complexity: O(dim^2)
*
* @param {number[]} p
* @param {number[]} w Euclidean coordinates of point <i>p</i>
* @return {number} the squared length of <i>w</i>
*/
shortestVectorToSpan(p: number[], w: number[]): number;
/**
* Use this for testing only; the method allocates additional storage and copies point
* coordinates.
* @return {number}
*/
representationError(): number;
/**
* Calculates the `size()`-many coefficients in the representation of <i>p</i> as an affine
* combination of the points <i>M</i>.
*
* The <i>i</i>th computed coefficient `lambdas[i] `corresponds to the <i>i</i>th point in
* <i>M</i>, or, in other words, to the point in <i>S</i> with index `globalIndex(i)`.
*
* Complexity: O(dim^2)
*
* Preconditions: c lies in the affine hull aff(M) and size() > 0.
* @param {number[]|Float64Array} p
* @param {number[]|Float64Array} lambdas
*/
findAffineCoefficients(p: number[] | Float64Array, lambdas: number[] | Float64Array): void;
/**
* Given <i>R</i> in lower Hessenberg form with subdiagonal entries 0 to `pos-1` already all
* zero, clears the remaining subdiagonal entries via Givens rotations.
* @param {number} pos
* @private
*/
private hessenberg_clear;
/**
* Update current QR-decomposition <i>A = QR</i> to
*
* <pre>
* A + u * [1,...,1] = Q' R'.
* </pre>
* @private
*/
private special_rank_1_update;
/**
*
* @param {number} index
*/
remove(index: number): void;
}
import { BitSet } from "../../../binary/BitSet.js";
//# sourceMappingURL=Subspan.d.ts.map