import { ATypedArrayTuple, TTypedArrayTupleMutativeMethods } from "../a-typed-array-tuple.js"; import { TTypedArray } from "../t-typed-array.js"; import { IReadonlyMat3 } from "../mat3/mat3.js"; import { ITypedArrayTupleFactory } from "../i-typed-array-tuple-factory.js"; import { TTypedArrayCtor } from "../t-typed-array-ctor.js"; import { IReadonlyRange2d } from "../2d/range2d/range2d.js"; import { TPickExcept } from "../../../typescript/t-pick-except.js"; /** * @public */ export type TVec2CtorArgs = [x: number, y: number]; /** * @public * Constructor for {@link Vec2}. */ export interface IVec2Ctor { readonly BASE: TTypedArrayCtor; /** * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; readonly prototype: Vec2; readonly factory: ITypedArrayTupleFactory, TVec2CtorArgs>; new (): Vec2; } /** * @public * {@link Vec2}. */ export interface IReadonlyVec2 extends TPickExcept>, "update" | "setX" | "setY" | "bound2d" | "translate2d" | "copyFromBuffer" | TTypedArrayTupleMutativeMethods> { } /** * @public * Vector 2. * * @remarks * See static properties for constructors. Instances are not an extension of this class, but of the static members. */ export declare abstract class Vec2 extends ATypedArrayTuple<2, TArray> { static f64: IVec2Ctor; static f32: IVec2Ctor; static i64: null; static u64: null; static u32: IVec2Ctor; static i32: IVec2Ctor; static u16: IVec2Ctor; static i16: IVec2Ctor; static u8c: IVec2Ctor; static u8: IVec2Ctor; static i8: IVec2Ctor; static getCtor(ctor: TCtor): IVec2Ctor>; protected static constructors: Map; ["constructor"]: IVec2Ctor; /** * x */ 0: number; /** * y */ 1: number; /** * Component-wise equals. */ isEqualTo(_other: Vec2): boolean; getX(): number; getY(): number; getMagnitude(): number; getMagnitudeSquared(): number; update(_x: number, _y: number): void; setX(_x: number): void; setY(_y: number): void; add(_vec: IReadonlyVec2, _result?: Vec2): Vec2; subtract(_vec: IReadonlyVec2, _result?: Vec2): Vec2; scalarMultiply(_value: number, _result?: Vec2): Vec2; /** * Multiply `this` by `_value`. */ vec2Multiply(_value: IReadonlyVec2, _result?: Vec2): Vec2; scalarDivide(_value: number, _result?: Vec2): Vec2; /** * Divide `this` by `_value`. */ vec2Divide(_value: IReadonlyVec2, _result?: Vec2): Vec2; /** * Returns a unit vector in the direction of this vector. */ normalize(_result?: Vec2): Vec2; /** * Returns the normal to this vector. */ getNormal(_result?: Vec2): Vec2; dotProduct(_vec: IReadonlyVec2): number; mat3Multiply(_mat: IReadonlyMat3, _result?: Vec2): Vec2; /** * If this point is outside of the range, set that dimension to the extrema of the range. * @param _range - The range to be bound to, inclusive. */ bound2d(_range: IReadonlyRange2d): void; /** * Shifts this position by the arguments. */ translate2d(_dx: number, _dy: number): void; getLoggableValue(): number[][]; /** * If endianness is not supplied the platform's endianness will be used. */ copyFromBuffer(_memoryDataView: DataView, _pointer: number, _littleEndian?: boolean): void; /** * If endianness is not supplied the platform's endianness will be used. */ copyToBuffer(_memoryDataView: DataView, _pointer: number, _littleEndian?: boolean): void; /** * Although the typed array tuples extend a typed array, they are not structurally compatible. * This function returns the argument passed without modification but cast as the underlying storage type, e.g. Float32Array. */ castToBaseType(): TArray; TTypeGuardVec2: true; } /** * @public * Float32 {@link Vec2}. */ export type TF32Vec2 = Vec2; /** * @public * Float64 {@link Vec2}. */ export type TF64Vec2 = Vec2; //# sourceMappingURL=vec2.d.ts.map