import { mat2 } from './mat2'; import { mat2d } from './mat2d'; import { mat3 } from './mat3'; import { vec3 } from './vec3'; /** * Represents 2D vector * @category Types */ export type vec2 = readonly [x: number, y: number]; /** * Functions for {@link vec2}, a 2D vector. * @category Modules */ export declare namespace vec2 { /** * Mutable version of {@link vec2} * @category Types */ type Mutable = [x: number, y: number]; /** * Creates a new vector from given elements * @category Generators */ function of(x: number, y?: number): vec2; /** * Creates a mutable clone of given vec2 * @category Generators */ function clone(a: vec2): Mutable; /** * @category Constants */ const zero: vec2; /** * @category Constants */ const one: vec2; /** * A unit vector pointing toward positive X. Same as `[1, 0]` * @category Constants */ const unitX: vec2; /** * A unit vector pointing toward positive Y. Same as `[0, 1]` * @category Constants */ const unitY: vec2; /** * Adds the given vectors */ function add(...vs: (vec2 | number)[]): vec2; /** * Subtracts the given vec2's. When the argument is a single vector, it negates it. Otherwise, it subtracts from left to right. * * @shorthands * - {@link sub} */ function subtract(...vs: (vec2 | number)[]): vec2; /** * Alias for {@link vec2.subtract} * @category Shorthands */ const sub: typeof subtract; /** * Subtracts `a` from `b` component-wise */ function delta(a: vec2 | number, b: vec2 | number): vec2; /** * Multiplies the given vec2's component-wise * * @shorthands * - {@link mul} */ function multiply(...vs: (vec2 | number)[]): vec2; /** * Alias for {@link vec2.multiply} * @category Shorthands */ const mul: typeof multiply; /** * Divides the given vec2's component-wise * * @shorthands * - {@link div} */ function divide(...vs: (vec2 | number)[]): vec2; /** * Alias for {@link vec2.divide} * @category Shorthands */ const div: typeof divide; /** * Returns the component-wise minimum of the given vec2's */ function min(...vs: (vec2 | number)[]): vec2; /** * Returns the component-wise maximum of the given vec2's */ function max(...vs: (vec2 | number)[]): vec2; /** * Constrain a value to lie between two further values * @see https://thebookofshaders.com/glossary/?search=clamp * @param v the value to constrain * @param min the lower end of the range into which to constrain `v` * @param max the upper end of the range into which to constrain `v` */ function clamp(v: vec2, min: vec2 | number, max: vec2 | number): vec2; /** * Clamps each component to [0, 1]. Equivalent to {@link saturate}. */ function clamp01(v: vec2): vec2; /** * Clamps each component to [-1, 1] */ function clamp11(v: vec2): vec2; /** * Returns the absolute value of each component of a vec2 */ function abs(v: vec2): vec2; /** * Symmetric round the components of a vec2 */ function round(a: vec2): vec2; /** * Applies Math.ceil to each component of a vec2 */ function ceil(a: vec2): vec2; /** * Applies Math.floor to each component of a vec2 */ function floor(a: vec2): vec2; /** * Applies Math.sign to each component of a vec2 */ function sign(v: vec2): vec2; /** * Removes the fractional part * @see https://www.sidefx.com/docs/houdini/vex/functions/trunc.html */ function trunc(v: vec2): vec2; /** * Computes the fractional part of the argument * @see https://registry.khronos.org/OpenGL-Refpages/gl4/html/fract.xhtml */ function fract(a: vec2): vec2; /** * Computes the value of one parameter modulo another. This is computed as x - y * floor(x/y). Unlike JavaScript's `%` operator, the sign of result always matches to `b`. * @see https://thebookofshaders.com/glossary/?search=mod */ function mod(a: vec2, b: vec2 | number): vec2; /** * Quantize a vec2 to a given step and offset. If the step is 0, the value is returned unchanged. * @param v The value to quantize * @param step The step size * @param offset The offset * @returns The quantized value */ function quantize(v: vec2, step: vec2 | number, offset?: vec2 | number): vec2; /** * Scales a vec2 by a scalar number * * @param a the vector to scale * @param s amount to scale the vector by */ function scale(a: vec2, s: number): vec2; /** * Returns the average value of the input(s) * @see https://www.sidefx.com/docs/houdini/vex/functions/avg.html * * @shorthands * - {@link avg} */ function average(...vs: vec2[]): vec2; /** * Alias for {@link vec2.average} * @category Shorthands */ const avg: typeof average; /** Adds given vec2's after scaling the second operand by a scalar value */ function scaleAndAdd(a: vec2, b: vec2, scale: number): vec2; /** * Calculates the euclidian distance between two vec2's * * @shorthands * - {@link dist} */ function distance(a: vec2, b: vec2): number; /** * Alias for {@link vec2.distance} * @category Shorthands */ const dist: typeof distance; /** * Calculates the squared euclidian distance between two vec2's * * @shorthands * - {@link sqrDist} */ function squaredDistance(a: vec2, b: vec2): number; /** * Alias for {@link vec2.squaredDistance} * @category Shorthands */ const sqrDist: typeof squaredDistance; /** * Returns the absolute difference between corresponding components of two vec2's * * @shorthands * - {@link diff} */ function difference(a: vec2, b: vec2): vec2; /** * Alias for {@link vec2.difference} * @category Shorthands */ const diff: typeof difference; /** * Calculates the length of a vec2 * * @shorthands * - {@link len} */ function length(v: vec2): number; /** * Alias for {@link vec2.length} * @category Shorthands */ const len: typeof length; /** * Calculates the squared length of a vec2 * * @shorthands * - {@link sqrLen} */ function squaredLength(v: vec2): number; /** * Alias for {@link vec2.squaredLength} * @category Shorthands */ const sqrLen: typeof squaredLength; /** * Negates the components of a vec2 * * @shorthands * - {@link neg} */ function negate(v: vec2): vec2; /** * Alias for {@link vec2.negate} * @category Shorthands */ const neg: typeof negate; /** * Returns the inverse of the components of a vec2 * * @shorthands * - {@link inv} */ function invert(v: vec2): vec2; /** * Alias for {@link vec2.invert} * @category Shorthands */ const inv: typeof invert; /** * Returns the result of `v` subtracted from {@link vec2.one}. */ function oneMinus(v: vec2): vec2; /** * Normalizes a vec2 to unit length. Returns the zero vector if the input has zero length. */ function normalize(v: vec2): vec2; /** * Calculates the dot product of two vec2's */ function dot(a: vec2, b: vec2): number; /** * Computes the cross product of two vec2's. Returns a vec3 with x and y components set to 0. */ function cross(a: vec2, b: vec2): vec3; /** * Reflects incident vector `I` about normal `N`. The normal `N` should be normalized. * @see https://registry.khronos.org/OpenGL-Refpages/gl4/html/reflect.xhtml * @param I Incident vector * @param N Normal vector (should be normalized) */ function reflect(I: vec2, N: vec2): vec2; /** * Computes the refraction vector for incident vector `I`, surface normal `N`, and ratio of indices of refraction `eta`. The normal `N` should be normalized. * @see https://registry.khronos.org/OpenGL-Refpages/gl4/html/refract.xhtml * @param I Incident vector * @param N Normal vector (should be normalized) * @param eta Ratio of indices of refraction * @returns The refraction vector, or zero vector for total internal reflection */ function refract(I: vec2, N: vec2, eta: number): vec2; /** * Orients a normal to point away from a surface as defined by its incident vector. Returns `N` if `dot(Nref, I) < 0`, otherwise returns `-N`. * @see https://registry.khronos.org/OpenGL-Refpages/gl4/html/faceforward.xhtml * @param N Normal vector * @param I Incident vector * @param Nref Reference normal */ function faceforward(N: vec2, I: vec2, Nref: vec2): vec2; /** * Projects vector `a` onto vector `b`. * @param a The vector to project * @param b The vector to project onto */ function project(a: vec2, b: vec2): vec2; /** * Computes the rejection of vector `a` from vector `b` (the component of `a` perpendicular to `b`). * @param a The vector to reject * @param b The vector to reject from */ function reject(a: vec2, b: vec2): vec2; /** * Linearly interpolates between two vec2's. Same as GLSL's built-in `mix` function. * @see https://registry.khronos.org/OpenGL-Refpages/gl4/html/mix.xhtml * * @shorthands * - {@link mix} */ function lerp(a: vec2, b: vec2, t: vec2 | number): vec2; /** * Alias for {@link vec2.lerp} * @see https://registry.khronos.org/OpenGL-Refpages/gl4/html/mix.xhtml * @category Shorthands */ const mix: typeof lerp; /** * Returns the amount to mix `min` and `max` to generate the input value `t`. This is the inverse of the `lerp` function. If `min` and `max` are equal, the mixing value is `0.5`. * @see https://docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/Inverse-Lerp-Node.html * @see https://www.sidefx.com/docs/houdini/vex/functions/invlerp.html * * @shorthands * - {@link invlerp} */ function inverseLerp(a: vec2, b: vec2, t: vec2): vec2; /** * Alias for {@link vec2.inverseLerp} * @category Shorthands */ const invlerp: typeof inverseLerp; /** * Performs a spherical linear interpolation between two vec2's */ function slerp(a: vec2, b: vec2, t: number): vec2; /** * Performs a hermite interpolation with two control points * * @param a the first operand * @param b the second operand * @param c the third operand * @param d the fourth operand * @param t interpolation amount, in the range [0-1], between the two inputs */ function hermite(a: vec2, b: vec2, c: vec2, d: vec2, t: number): vec2; /** * Performs a bezier interpolation with two control points */ function bezier(a: vec2, b: vec2, c: vec2, d: vec2, t: number): vec2; /** * Takes the value in the range `(omin, omax)` and shifts it to the corresponding value in the new range `(nmin, nmax)`. The function clamps the given value the range `(omin, omax)` before fitting, so the resulting value will be guaranteed to be in the range `(nmin, nmax)`. To avoid clamping use efit instead. * @see https://www.sidefx.com/docs/houdini/vex/functions/fit.html * @param value * @param omin * @param omax * @param nmin * @param nmax * @returns */ function fit(value: vec2, omin: vec2, omax: vec2, nmin: vec2, nmax: vec2): vec2; /** * Takes the value in the range `(omin, omax)` and shifts it to the corresponding value in the new range `(nmin, nmax)`. Unlike `fit`, this function does not clamp values to the given range. If `omin` and `omax` are the same, the function returns the average of `nmin` and `nmax`. * @see https://www.sidefx.com/docs/houdini/vex/functions/fit.html * @param value * @param omin * @param omax * @param nmin * @param nmax * @returns */ function efit(value: vec2, omin: vec2, omax: vec2, nmin: vec2, nmax: vec2): vec2; /** * Takes the value in the range `(0, 1)` and shifts it to the corresponding value in the new range `(nmin, nmax)`. * @see https://www.sidefx.com/docs/houdini/vex/functions/fit01.html */ function fit01(value: vec2, nmin: vec2, nmax: vec2): vec2; /** * Takes the value in the range `(-1, 1)` and shifts it to the corresponding value in the new range `(nmin, nmax)`. * @see https://www.sidefx.com/docs/houdini/vex/functions/fit11.html */ function fit11(value: vec2, nmin: vec2, nmax: vec2): vec2; /** * Transforms the vec2 with a mat2 */ function transformMat2(a: vec2, m: mat2): vec2; /** * Transforms the vec2 with a mat2d * 3rd vector component is implicitly '1' */ function transformMat2d(a: vec2, m: mat2d): vec2; /** * Transforms the vec2 with a mat3 * 3rd vector component is implicitly '1' */ function transformMat3(a: vec2, m: mat3): vec2; /** * Transforms a vec2 with a matrix, automatically choosing the appropriate transformation function based on matrix size * @param p The vector to transform * @param m The transformation matrix (mat2, mat2d, or mat3) * @returns The transformed vector * * @shorthands * - {@link xform} */ function transform(p: vec2, m: mat2 | mat2d | mat3): vec2; /** * Alias for {@link vec2.transform} * @category Shorthands */ const xform: typeof transform; /** * Rotate a 2D vector */ function rotate(a: vec2, deg: number, origin?: vec2): vec2; /** * Rotates a vector by 90 degrees * @param a the vector to rotate * @param sweep If true, the rotation is in positive direction. For example, it means clockwise rotation in a Y-down coordinate system. * @param origin The origin of the rotation * @returns The rotated vector */ function rotate90(a: vec2, sweep?: boolean, origin?: vec2): vec2; /** * Get the angle between two 2D vectors. If the second argument is omitted, it returns a signed angle relative to x axis. * @param a The first vector * @param b The second vector * @returns The angle in degrees. If the angle from a to b is clockwise, the return value is positive. Otherwise, it is negative. The range is (-180, 180]. */ function angle(a: vec2, b?: vec2): number; /** * Creates a vector by given direction, length, and origin * @param deg The direction in degrees * @param length The length of the vector to create. Default is 1 * @param origin The origin of the vector. Default is [0, 0] * * @shorthands * - {@link dir} */ function direction(deg: number, length?: number, origin?: vec2): vec2; /** * Alias for {@link vec2.direction} * @category Shorthands */ const dir: typeof direction; /** * Apply a step function by comparing two values * @see https://registry.khronos.org/OpenGL-Refpages/gl4/html/step.xhtml * @param edge The location of the edge of the step function. * @param v The value to be used to generate the step function. * @returns */ function step(edge: vec2 | number, v: vec2 | number): vec2; /** * Perform Hermite interpolation between two values. * @see https://registry.khronos.org/OpenGL-Refpages/gl4/html/smoothstep.xhtml * @param edge0 Lower edge of the Hermite function. * @param edge1 Upper edge of the Hermite function. * @param x Source value for interpolation. * @returns */ function smoothstep(edge0: vec2 | number, edge1: vec2 | number, x: vec2): number[]; /** * Converts the components of a vec2 from radians to degrees * @param rad The input vec2 in radians * @returns The degrees equivalent of the input * * @shorthands * - {@link deg} */ function degrees(rad: vec2): vec2; /** * Alias for {@link vec2.degrees} * @category Shorthands */ const deg: typeof degrees; /** * Converts the components of a vec2 from degrees to radians * @param deg The input vec2 in degrees * @returns The radians equivalent of the input * * @shorthands * - {@link rad} */ function radians(deg: vec2): vec2; /** * Alias for {@link vec2.radians} * @category Shorthands */ const rad: typeof radians; /** * Returns the sine of a number. * @param deg An angle in degrees */ function sin(deg: vec2): vec2; /** * Returns the cosine of a number. * @param deg An angle in degrees */ function cos(deg: vec2): vec2; /** * Returns the tangent of a number. * @param deg An angle in degrees */ function tan(deg: vec2): vec2; /** * Returns the arcsine of a number. * @param v A numeric expression. * @returns The arcsine in degrees * */ function asin(v: vec2): vec2; /** * Returns the arc cosine (or inverse cosine) of a number. * @param v A numeric expression. * @returns The arc cosine in degrees * */ function acos(v: vec2): vec2; /** * Returns the arc-tangent of the parameters. If `x` is not provided, `y` is regarded as a value of `y/x`. * @param y the values of the y-coordinate * @param x the values of the x-coordinate * @returns the angle in degrees * @see https://thebookofshaders.com/glossary/?search=atan * */ function atan(y: vec2, x?: vec2): vec2; /** * Returns the arc-tangent of the parameters. * @param y the values of the y-coordinate * @param x the values of the x-coordinate * @returns the angle in degrees * @see https://thebookofshaders.com/glossary/?search=atan * */ function atan2(y: vec2, x: vec2): vec2; /** * Returns the base to the exponent power, component-wise */ function pow(a: vec2, b: vec2 | number): vec2; /** * Returns e raised to the power of each component */ function exp(v: vec2): vec2; /** * Returns the natural logarithm of each component */ function log(v: vec2): vec2; /** * Returns 2 raised to the power of the parameter * @param v the value of the power to which 2 will be raised */ function exp2(v: vec2): vec2; /** * Returns the base-2 logarithm of each component */ function log2(v: vec2): vec2; /** * Returns the square root of each component */ function sqrt(v: vec2): vec2; /** * Returns the inverse of the square root of the parameter * @param v the value of which to take the inverse of the square root * @see https://thebookofshaders.com/glossary/?search=inversesqrt * * @shorthands * - {@link invsqrt} */ function inverseSqrt(v: vec2): vec2; /** * Alias for {@link vec2.inverseSqrt} * @category Shorthands */ const invsqrt: typeof inverseSqrt; /** * Returns the hyperbolic sine of each component */ function sinh(v: vec2): vec2; /** * Returns the hyperbolic cosine of each component */ function cosh(v: vec2): vec2; /** * Returns the hyperbolic tangent of each component */ function tanh(v: vec2): vec2; /** * Returns the inverse hyperbolic sine of each component */ function asinh(v: vec2): vec2; /** * Returns the inverse hyperbolic cosine of each component */ function acosh(v: vec2): vec2; /** * Returns the inverse hyperbolic tangent of each component */ function atanh(v: vec2): vec2; /** * Clamps each component to [0, 1]. Equivalent to HLSL's `saturate`. */ function saturate(v: vec2): vec2; /** * Returns the sum of all components of a vector. * Equivalent to GLM's `glm::compAdd`. */ function compAdd(v: vec2): number; /** * Returns the product of all components of a vector. * Equivalent to GLM's `glm::compMul`. */ function compMul(v: vec2): number; /** * Returns whether or not the vectors exactly have the same elements in the same position (when compared with `===`) * * @shorthands * - {@link eq} */ function exactEquals(a: vec2, b: vec2): boolean; /** * Alias for {@link exactEquals} * @category Shorthands */ const eq: typeof exactEquals; /** * Returns whether or not the vectors have approximately the same elements in the same position. * * @shorthands * - {@link approx} * - {@link equals} */ function approxEquals(a: vec2, b: vec2): boolean; /** * Alias for {@link approxEquals} * @category Shorthands */ const approx: typeof approxEquals; /** * Alias for {@link approxEquals}. This is provided for compatibility with gl-matrix. * @category Shorthands * @deprecated Use {@link approxEquals} instead */ const equals: typeof approxEquals; /** * Returns the string representation of a vec2 * @param v vector to represent as a string * @param fractionDigits number of digits to appear after the decimal point */ const toString: (v: vec2, fractionDigits?: number) => string; } //# sourceMappingURL=vec2.d.ts.map