import type { b2Readonly } from "./b2_readonly"; export declare const b2_pi_over_180: number; export declare const b2_180_over_pi: number; export declare const b2_two_pi: number; export declare function b2Clamp(a: number, low: number, high: number): number; export declare function b2DegToRad(degrees: number): number; export declare function b2RadToDeg(radians: number): number; /** * "Next Largest Power of 2 * Given a binary integer value x, the next largest power of 2 can be computed by a SWAR algorithm * that recursively "folds" the upper bits into the lower bits. This process yields a bit vector with * the same most significant 1 as x, but all 1's below it. Adding 1 to that value yields the next * largest power of 2. For a 32-bit value:" */ export declare function b2NextPowerOfTwo(x: number): number; export declare function b2IsPowerOfTwo(x: number): boolean; export declare function b2Random(): number; export declare function b2RandomFloat(lo: number, hi: number): number; export declare function b2RandomInt(lo: number, hi: number): number; export interface XY { x: number; y: number; } /** * A 2D column vector. */ export declare class b2Vec2 implements XY { static readonly ZERO: b2Readonly; static readonly UNITX: b2Readonly; static readonly UNITY: b2Readonly; static readonly s_t0: b2Vec2; static readonly s_t1: b2Vec2; static readonly s_t2: b2Vec2; static readonly s_t3: b2Vec2; x: number; y: number; constructor(x?: number, y?: number); Clone(): b2Vec2; /** * Set this vector to all zeros. */ SetZero(): this; /** * Set this vector to some specified coordinates. */ Set(x: number, y: number): this; Copy(other: Readonly): this; /** * Add a vector to this vector. */ Add(v: Readonly): this; /** * Add a vector to this vector. */ AddXY(x: number, y: number): this; /** * Subtract a vector from this vector. */ Subtract(v: Readonly): this; /** * Subtract a vector from this vector. */ SubtractXY(x: number, y: number): this; /** * Multiply this vector by a scalar. */ Scale(s: number): this; AddScaled(s: number, v: Readonly): this; SubtractScaled(s: number, v: Readonly): this; /** * Perform the dot product on two vectors. */ Dot(v: Readonly): number; /** * Perform the cross product on two vectors. In 2D this produces a scalar. */ Cross(v: Readonly): number; /** * Get the length of this vector (the norm). */ Length(): number; /** * Get the length squared. For performance, use this instead of * b2Vec2::Length (if possible). */ LengthSquared(): number; /** * Convert this vector into a unit vector. Returns the length. */ Normalize(): number; Rotate(radians: number): this; RotateCosSin(c: number, s: number): this; /** * Does this vector contain finite coordinates? */ IsValid(): boolean; Abs(): this; GetAbs(out: T): T; /** * Negate this vector. */ Negate(): this; /** * Skew this vector such that dot(skew_vec, other) == cross(vec, other) */ Skew(): this; static Min(a: Readonly, b: Readonly, out: T): T; static Max(a: Readonly, b: Readonly, out: T): T; static Clamp(v: Readonly, lo: Readonly, hi: Readonly, out: T): T; static Rotate(v: Readonly, radians: number, out: T): T; /** Perform the dot product on two vectors. */ static Dot(a: Readonly, b: Readonly): number; /** Perform the cross product on two vectors. In 2D this produces a scalar. */ static Cross(a: Readonly, b: Readonly): number; /** * Perform the cross product on a vector and a scalar. In 2D this produces * a vector. */ static CrossVec2Scalar(v: Readonly, s: number, out: T): T; static CrossVec2One(v: Readonly, out: T): T; /** * Perform the cross product on a scalar and a vector. In 2D this produces * a vector. */ static CrossScalarVec2(s: number, v: Readonly, out: T): T; static CrossOneVec2(v: Readonly, out: T): T; /** * Add two vectors component-wise. */ static Add(a: Readonly, b: Readonly, out: T): T; /** * Subtract two vectors component-wise. */ static Subtract(a: Readonly, b: Readonly, out: T): T; static Scale(s: number, v: Readonly, out: T): T; static AddScaled(a: Readonly, s: number, b: Readonly, out: T): T; static SubtractScaled(a: Readonly, s: number, b: Readonly, out: T): T; static AddCrossScalarVec2(a: Readonly, s: number, v: Readonly, out: T): T; static Mid(a: Readonly, b: Readonly, out: T): T; static Extents(a: Readonly, b: Readonly, out: T): T; static Equals(a: Readonly, b: Readonly): boolean; static Distance(a: Readonly, b: Readonly): number; static DistanceSquared(a: Readonly, b: Readonly): number; /** * Negate a vector. */ static Negate(v: Readonly, out: T): T; static Normalize(v: Readonly, out: T): T; /** * Skew a vector such that dot(skew_vec, other) == cross(vec, other) */ static Skew(v: Readonly, out: T): T; } export interface XYZ extends XY { z: number; } /** * A 2D column vector with 3 elements. */ export declare class b2Vec3 implements XYZ { static readonly ZERO: b2Readonly; static readonly s_t0: b2Vec3; x: number; y: number; z: number; constructor(x?: number, y?: number, z?: number); Clone(): b2Vec3; /** * Set this vector to all zeros. */ SetZero(): this; /** * Set this vector to some specified coordinates. */ Set(x: number, y: number, z: number): this; Copy(other: Readonly): this; /** * Negate this vector. */ Negate(): this; /** * Add a vector to this vector. */ Add(v: Readonly): this; /** * Add a vector to this vector. */ AddXYZ(x: number, y: number, z: number): this; /** * Subtract a vector from this vector. */ Subtract(v: Readonly): this; /** * Subtract a vector from this vector. */ SubtractXYZ(x: number, y: number, z: number): this; /** * Multiply this vector by a scalar. */ Scale(s: number): this; /** * Perform the dot product on two vectors. */ static Dot(a: Readonly, b: Readonly): number; /** * Perform the cross product on two vectors. */ static Cross(a: Readonly, b: Readonly, out: T): T; } /** * A 2-by-2 matrix. Stored in column-major order. */ export declare class b2Mat22 { static readonly IDENTITY: b2Readonly; readonly ex: b2Vec2; readonly ey: b2Vec2; Clone(): b2Mat22; /** * Construct a matrix using columns. */ static FromColumns(c1: Readonly, c2: Readonly): b2Mat22; /** * Construct a matrix using scalars. */ static FromScalars(r1c1: number, r1c2: number, r2c1: number, r2c2: number): b2Mat22; static FromAngle(radians: number): b2Mat22; /** * Set this matrix using scalars. */ SetScalars(r1c1: number, r1c2: number, r2c1: number, r2c2: number): this; /** * Initialize this matrix using columns. */ SetColumns(c1: Readonly, c2: Readonly): this; SetAngle(radians: number): this; Copy(other: b2Readonly): this; /** * Set this to the identity matrix. */ SetIdentity(): this; /** * Set this matrix to all zeros. */ SetZero(): this; GetAngle(): number; /** * Solve A * x = b, where b is a column vector. This is more efficient * than computing the inverse in one-shot cases. */ Solve(b_x: number, b_y: number, out: T): T; Abs(): this; Inverse(): this; Add(M: b2Readonly): this; Subtract(M: b2Readonly): this; GetInverse(out: b2Mat22): b2Mat22; GetAbs(out: b2Mat22): b2Mat22; /** * Multiply a matrix times a vector. If a rotation matrix is provided, * then this transforms the vector from one frame to another. */ static MultiplyVec2(M: b2Readonly, v: Readonly, out: T): T; /** * Multiply a matrix transpose times a vector. If a rotation matrix is provided, * then this transforms the vector from one frame to another (inverse transform). */ static TransposeMultiplyVec2(M: b2Readonly, v: Readonly, out: T): T; static Add(A: b2Readonly, B: b2Readonly, out: b2Mat22): b2Mat22; /** A * B */ static Multiply(A: b2Readonly, B: b2Readonly, out: b2Mat22): b2Mat22; /** A^T * B */ static TransposeMultiply(A: b2Readonly, B: b2Readonly, out: b2Mat22): b2Mat22; } /** * A 3-by-3 matrix. Stored in column-major order. */ export declare class b2Mat33 { static readonly IDENTITY: b2Readonly; readonly ex: b2Vec3; readonly ey: b2Vec3; readonly ez: b2Vec3; Clone(): b2Mat33; /** * Set this matrix using columns. */ SetColumns(c1: Readonly, c2: Readonly, c3: Readonly): this; Copy(other: b2Readonly): this; SetIdentity(): this; /** * Set this matrix to all zeros. */ SetZero(): this; Add(M: b2Readonly): this; /** * Solve A * x = b, where b is a column vector. This is more efficient * than computing the inverse in one-shot cases. */ Solve33(b_x: number, b_y: number, b_z: number, out: T): T; /** * Solve A * x = b, where b is a column vector. This is more efficient * than computing the inverse in one-shot cases. Solve only the upper * 2-by-2 matrix equation. */ Solve22(b_x: number, b_y: number, out: T): T; /** * Get the inverse of this matrix as a 2-by-2. * Returns the zero matrix if singular. */ GetInverse22(M: b2Mat33): void; /** * Get the symmetric inverse of this matrix as a 3-by-3. * Returns the zero matrix if singular. */ GetSymInverse33(M: b2Mat33): void; /** * Multiply a matrix times a vector. */ static MultiplyVec3(A: b2Readonly, v: Readonly, out: T): T; /** * Multiply a matrix times a vector. */ static MultiplyVec2(A: b2Readonly, v: Readonly, out: T): T; } /** * Rotation */ export declare class b2Rot { static readonly IDENTITY: b2Readonly; /** Sine */ s: number; /** Cosine */ c: number; /** * Initialize from an angle in radians */ constructor(angle?: number); Clone(): b2Rot; Copy(other: b2Readonly): this; /** * Set using an angle in radians. */ Set(angle: number): this; /** * Set to the identity rotation */ SetIdentity(): this; /** * Get the angle in radians */ GetAngle(): number; /** * Get the x-axis */ GetXAxis(out: T): T; /** * Get the u-axis */ GetYAxis(out: T): T; /** * Multiply two rotations: q * r */ static Multiply(q: b2Readonly, r: b2Readonly, out: b2Rot): b2Rot; /** * Transpose multiply two rotations: qT * r */ static TransposeMultiply(q: b2Readonly, r: b2Readonly, out: b2Rot): b2Rot; /** * Rotate a vector */ static MultiplyVec2(q: b2Readonly, v: Readonly, out: T): T; /** * Inverse rotate a vector */ static TransposeMultiplyVec2(q: b2Readonly, v: Readonly, out: T): T; } /** * A transform contains translation and rotation. It is used to represent * the position and orientation of rigid frames. */ export declare class b2Transform { static readonly IDENTITY: b2Readonly; readonly p: b2Vec2; readonly q: b2Rot; Clone(): b2Transform; Copy(other: b2Readonly): this; /** * Set this to the identity transform. */ SetIdentity(): this; /** * Set this based on the position and rotation. */ SetPositionRotation(position: Readonly, q: b2Readonly): this; /** * Set this based on the position and angle. */ SetPositionAngle(pos: Readonly, a: number): this; SetPosition(position: Readonly): this; SetPositionXY(x: number, y: number): this; SetRotation(rotation: b2Readonly): this; SetRotationAngle(radians: number): this; GetPosition(): b2Readonly; GetRotation(): b2Readonly; GetAngle(): number; static MultiplyVec2(T: b2Readonly, v: Readonly, out: T): T; static TransposeMultiplyVec2(T: b2Readonly, v: Readonly, out: T): T; /** * v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p * = (A.q * B.q).Rot(v1) + A.q.Rot(B.p) + A.p */ static Multiply(A: b2Readonly, B: b2Readonly, out: b2Transform): b2Transform; /** * v2 = A.q' * (B.q * v1 + B.p - A.p) * = A.q' * B.q * v1 + A.q' * (B.p - A.p) */ static TransposeMultiply(A: b2Readonly, B: b2Readonly, out: b2Transform): b2Transform; } /** * This describes the motion of a body/shape for TOI computation. * Shapes are defined with respect to the body origin, which may * no coincide with the center of mass. However, to support dynamics * we must interpolate the center of mass position. */ export declare class b2Sweep { /** Local center of mass position */ readonly localCenter: b2Vec2; /** Center world position at time 0 */ readonly c0: b2Vec2; /** Center world position at time 1 */ readonly c: b2Vec2; /** World angle at time 0 */ a0: number; /** World angle at time 1 */ a: number; /** * Fraction of the current time step in the range [0,1] * c0 and a0 are the positions at alpha0. */ alpha0: number; Clone(): b2Sweep; Copy(other: b2Sweep): this; /** * Get the interpolated transform at a specific time. * * @param transform The output transform * @param beta Is a factor in [0,1], where 0 indicates alpha0. * @see https://fgiesen.wordpress.com/2012/08/15/linear-interpolation-past-present-and-future/ */ GetTransform(xf: b2Transform, beta: number): b2Transform; /** * Advance the sweep forward, yielding a new initial state. * * @param alpha The new initial time. */ Advance(alpha: number): void; /** * Normalize an angle in radians to be between -pi and pi */ Normalize(): void; } //# sourceMappingURL=b2_math.d.ts.map