{"version":3,"file":"vector3-CR2LPV03.mjs","names":["internal.isVector3","internal.equals","internal.make","internal.fromTuple","internal.transpose","internal.fromSpherical","internal.magnitude","internal.normalize","internal.dot","internal.cross","internal.components","internal.softmax","internal.add","internal.subtract","internal.hadamard","internal.scale","internal.getX","internal.setX","internal.mapX","internal.getY","internal.setY","internal.mapY","internal.getZ","internal.setZ","internal.mapZ","internal.setR","internal.mapR","internal.getTheta","internal.setTheta","internal.mapTheta","internal.getPhi","internal.setPhi","internal.mapPhi"],"sources":["../../src/vector/vector3.ts"],"sourcesContent":["import type { ThreeDimensional } from '../dimensions.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { Vector3TypeId } from './vector3.internal.ts'\nimport * as internal from './vector3.internal.ts'\n\n/**\n * A 3D vector.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 1.0.0\n */\nexport interface Vector3 extends Pipeable, ThreeDimensional<number> {\n  readonly [Vector3TypeId]: Vector3TypeId\n}\n\n/**\n * Checks if a value is a `Vector3`.\n *\n * @param v - The value to check.\n * @returns `true` if the value is a `Vector3`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isVector3: (v: unknown) => v is Vector3 = internal.isVector3\n\nexport const equals: {\n  /**\n   * Checks if two `Vector3` instances are approximately equal within the\n   * default absolute tolerance ({@link EPSILON}).\n   *\n   * @param a - The first vector.\n   * @param b - The second vector.\n   * @returns `true` when each pair of components is within tolerance.\n   * @since 1.1.0\n   */\n  (a: Vector3, b: Vector3): boolean\n  /**\n   * Checks if two `Vector3` instances are approximately equal within the\n   * default absolute tolerance ({@link EPSILON}).\n   *\n   * @param b - The second vector.\n   * @returns A function that takes the first vector and returns the comparison result.\n   * @since 1.1.0\n   */\n  (b: Vector3): (a: Vector3) => boolean\n} = internal.equals\n\nexport const make: {\n  /**\n   * Creates a new `Vector3` instance.\n   *\n   * @param xyz - The x, y, and z components of the vector.\n   * @returns A new `Vector3` instance.\n   * @since 1.0.0\n   */\n  (xyz: number): Vector3\n  /**\n   * Creates a new `Vector3` instance.\n   *\n   * @param x - The x component of the vector.\n   * @param yz - The y and z components of the vector.\n   * @returns A new `Vector3` instance.\n   * @since 1.0.0\n   */\n  (x: number, yz: number): Vector3\n  /**\n   * Creates a new `Vector3` instance.\n   *\n   * @param x - The x component of the vector.\n   * @param y - The y component of the vector.\n   * @param z - The z component of the vector.\n   * @returns A new `Vector3` instance.\n   * @since 1.0.0\n   */\n  (x: number, y: number, z: number): Vector3\n} = internal.make\n\n/**\n * Creates a new `Vector3` instance from a `[x, y, z]` tuple. Inverse of\n * {@link components}.\n *\n * @param t - The `[x, y, z]` tuple.\n * @returns A new `Vector3` instance.\n * @since 2.0.0\n */\nexport const fromTuple: (t: readonly [number, number, number]) => Vector3 = internal.fromTuple\n\n/**\n * Transposes a 3-tuple of items into one or more `Vector3`s, one per channel\n * extracted by the projection function. See {@link Vector4.transpose} for the\n * full operation description; this is the 3-component analog.\n *\n * @param inputs - Exactly three items of any type.\n * @param project - A function returning a fixed-arity tuple of numbers — one per output channel.\n * @returns A tuple of `Vector3`s with the same arity as the projection's return tuple.\n * @since 2.0.0\n */\nexport const transpose: <T, const Channels extends ReadonlyArray<number>>(\n  inputs: readonly [T, T, T],\n  project: (item: T) => Channels,\n) => { readonly [K in keyof Channels]: Vector3 } = internal.transpose\n\n/**\n * Creates a new `Vector3` instance from spherical coordinates.\n *\n * @param r - The radius.\n * @param theta - The polar angle, in radians. Ranges from 0 to π\n * @param phi - The azimuthal angle, in radians. Ranges from 0 to 2π\n * @returns A new `Vector3` instance.\n * @since 1.0.0\n */\nexport const fromSpherical: (r: number, theta: number, phi: number) => Vector3 =\n  internal.fromSpherical\n\n/**\n * Calculates the magnitude of a `Vector3`.\n *\n * @param vector - The vector to calculate the magnitude of.\n * @returns The magnitude of the vector.\n * @since 1.0.0\n */\nexport const magnitude: (vector: Vector3) => number = internal.magnitude\n\n/**\n * Calculates the length of a `Vector3`.\n *\n * @param vector - The vector to calculate the length of.\n * @returns The length of the vector.\n * @see {@link magnitude}\n * @since 1.0.0\n */\nexport const length: (vector: Vector3) => number = magnitude\n\n/**\n * Normalizes a `Vector3`.\n *\n * @param vector - The vector to normalize.\n * @returns A new `Vector3` instance with the same direction as the input vector, but with a magnitude of 1.\n * @since 1.0.0\n */\nexport const normalize: (vector: Vector3) => Vector3 = internal.normalize\n\nexport const dot: {\n  /**\n   * Calculates the dot product of two `Vector3` instances.\n   *\n   * @param a - The first vector.\n   * @param b - The second vector.\n   * @returns The dot product of the two vectors.\n   * @since 1.0.0\n   */\n  (a: Vector3, b: Vector3): number\n  /**\n   * Calculates the dot product of two `Vector3` instances.\n   *\n   * @param b - The second vector.\n   * @returns A function that takes the first vector and returns the dot product.\n   * @since 1.0.0\n   */\n  (b: Vector3): (a: Vector3) => number\n} = internal.dot\n\nexport const cross: {\n  /**\n   * Calculates the cross product of two `Vector3` instances.\n   *\n   * @param a - The first vector.\n   * @param b - The second vector.\n   * @returns A new `Vector3` instance representing the cross product of the two vectors.\n   * @since 1.0.0\n   */\n  (a: Vector3, b: Vector3): Vector3\n  /**\n   * Calculates the cross product of two `Vector3` instances.\n   *\n   * @param b - The second vector.\n   * @returns A function that takes the first vector and returns the cross product.\n   * @since 1.0.0\n   */\n  (b: Vector3): (a: Vector3) => Vector3\n} = internal.cross\n\n/**\n * Returns the components of a `Vector3` as an array.\n *\n * @param v - The vector to get the components of.\n * @returns An array containing the x, y, and z components of the vector.\n * @since 1.0.0\n */\nexport const components: (v: Vector3) => [number, number, number] = internal.components\n\n/**\n * Calculates the softmax of a `Vector3`.\n *\n * @param v - The vector to calculate the softmax of.\n * @returns A new `Vector3` instance representing the softmax of the input vector.\n * @since 1.0.0\n */\nexport const softmax: (v: Vector3) => Vector3 = internal.softmax\n\n/**\n * Creates a zero vector.\n *\n * @since 1.0.0\n */\nexport const zero = make(0)\n\n/**\n * Creates a unit vector.\n *\n * @since 1.0.0\n */\nexport const unit = make(1)\n\n/**\n * Creates a unit vector in the x direction.\n *\n * @since 1.0.0\n */\nexport const unitX = make(1, 0, 0)\n\n/**\n * Creates a unit vector in the y direction.\n *\n * @since 1.0.0\n */\nexport const unitY = make(0, 1, 0)\n\n/**\n * Creates a unit vector in the z direction.\n *\n * @since 1.0.0\n */\nexport const unitZ = make(0, 0, 1)\n\nexport const add: {\n  /**\n   * Adds two `Vector3` instances.\n   *\n   * @param a - The first vector.\n   * @param b - The second vector.\n   * @returns A new `Vector3` instance representing the sum of the two vectors.\n   * @since 1.0.0\n   */\n  (a: Vector3, b: Vector3): Vector3\n  /**\n   * Adds two `Vector3` instances.\n   *\n   * @param b - The second vector.\n   * @returns A function that takes the first vector and returns the sum.\n   * @since 1.0.0\n   */\n  (b: Vector3): (a: Vector3) => Vector3\n} = internal.add\n\nexport const subtract: {\n  /**\n   * Subtracts one `Vector3` instance from another.\n   *\n   * @param a - The vector to subtract from.\n   * @param b - The vector to subtract.\n   * @returns A new `Vector3` instance representing the difference of the two vectors.\n   * @since 1.0.0\n   */\n  (a: Vector3, b: Vector3): Vector3\n  /**\n   * Subtracts one `Vector3` instance from another.\n   *\n   * @param b - The vector to subtract.\n   * @returns A function that takes the first vector and returns the difference.\n   * @since 1.0.0\n   */\n  (b: Vector3): (a: Vector3) => Vector3\n} = internal.subtract\n\nexport const hadamard: {\n  /**\n   * Calculates the Hadamard product of two `Vector3` instances.\n   *\n   * The Hadamard product is an element-wise multiplication of two vectors.\n   *\n   * @param a - The first vector.\n   * @param b - The second vector.\n   * @returns A new `Vector3` instance representing the Hadamard product of the two vectors.\n   * @since 1.0.0\n   */\n  (a: Vector3, b: Vector3): Vector3\n  /**\n   * Calculates the Hadamard product of two `Vector3` instances.\n   *\n   * The Hadamard product is an element-wise multiplication of two vectors.\n   *\n   * @param b - The second vector.\n   * @returns A function that takes the first vector and returns the Hadamard product.\n   * @since 1.0.0\n   */\n  (b: Vector3): (a: Vector3) => Vector3\n} = internal.hadamard\n\nexport const scale: {\n  /**\n   * Scales a `Vector3` instance by a scalar value.\n   *\n   * @param s - The scalar value to scale by.\n   * @return A function that takes a vector and returns the scaled vector.\n   * @since 1.0.0\n   */\n  (s: number): (v: Vector3) => Vector3\n  /**\n   * Scales a `Vector3` instance by a scalar value.\n   *\n   * @param s - The scalar value to scale by.\n   * @param v - The vector to scale.\n   * @returns A new `Vector3` instance representing the scaled vector.\n   * @since 1.0.0\n   */\n  (v: Vector3, s: number): Vector3\n} = internal.scale\n\n/**\n * Gets the x component of a `Vector3`.\n *\n * @param v - The vector to get the x component of.\n * @returns The x component of the vector.\n * @since 1.0.0\n */\nexport const getX: (v: Vector3) => number = internal.getX\n\nexport const setX: {\n  /**\n   * Sets the x component of a `Vector3`.\n   *\n   * @param v - The vector to set the x component of.\n   * @param x - The new x component.\n   * @returns A new `Vector3` instance with the updated x component.\n   * @since 1.0.0\n   */\n  (v: Vector3, x: number): Vector3\n  /**\n   * Sets the x component of a `Vector3`.\n   *\n   * @param x - The new x component.\n   * @returns A function that takes the vector and returns a new `Vector3` instance with the updated x component.\n   * @since 1.0.0\n   */\n  (x: number): (v: Vector3) => Vector3\n} = internal.setX\n\nexport const mapX: {\n  /**\n   * Returns a new `Vector3` with the x component replaced by `f(v.x)`.\n   *\n   * @param v - The vector to update.\n   * @param f - The function to apply to the x component.\n   * @returns A new `Vector3` with the updated x.\n   * @since 2.0.0\n   */\n  (v: Vector3, f: (x: number) => number): Vector3\n  /**\n   * Returns a new `Vector3` with the x component replaced by `f(v.x)`.\n   *\n   * @param f - The function to apply to the x component.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (f: (x: number) => number): (v: Vector3) => Vector3\n} = internal.mapX\n\n/**\n * Gets the y component of a `Vector3`.\n *\n * @param v - The vector of which to get the y component.\n * @returns The y component of the vector.\n * @since 1.0.0\n */\nexport const getY: (v: Vector3) => number = internal.getY\n\nexport const setY: {\n  /**\n   * Sets the y component of a `Vector3`.\n   *\n   * @param v - The vector of which to set the y component.\n   * @param y - The new y component.\n   * @returns A new `Vector3` instance with the updated y component.\n   * @since 1.0.0\n   */\n  (v: Vector3, y: number): Vector3\n  /**\n   * Sets the y component of a `Vector3`.\n   *\n   * @param y - The new y component.\n   * @returns A function that takes the vector and returns a new `Vector3` instance with the updated y component.\n   * @since 1.0.0\n   */\n  (y: number): (v: Vector3) => Vector3\n} = internal.setY\n\nexport const mapY: {\n  /**\n   * Returns a new `Vector3` with the y component replaced by `f(v.y)`.\n   *\n   * @param v - The vector to update.\n   * @param f - The function to apply to the y component.\n   * @returns A new `Vector3` with the updated y.\n   * @since 2.0.0\n   */\n  (v: Vector3, f: (y: number) => number): Vector3\n  /**\n   * Returns a new `Vector3` with the y component replaced by `f(v.y)`.\n   *\n   * @param f - The function to apply to the y component.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (f: (y: number) => number): (v: Vector3) => Vector3\n} = internal.mapY\n\n/**\n * Gets the z component of a `Vector3`.\n *\n * @param v - The vector of which to get the z component.\n * @returns The z component of the vector.\n * @since 1.0.0\n */\nexport const getZ: (v: Vector3) => number = internal.getZ\n\nexport const setZ: {\n  /**\n   * Sets the z component of a `Vector3`.\n   *\n   * @param v - The vector of which to set the z component.\n   * @param z - The new z component.\n   * @returns A new `Vector3` instance with the updated z component.\n   * @since 1.0.0\n   */\n  (v: Vector3, z: number): Vector3\n  /**\n   * Sets the z component of a `Vector3`.\n   *\n   * @param z - The new z component.\n   * @returns A function that takes the vector and returns a new `Vector3` instance with the updated z component.\n   * @since 1.0.0\n   */\n  (z: number): (v: Vector3) => Vector3\n} = internal.setZ\n\nexport const mapZ: {\n  /**\n   * Returns a new `Vector3` with the z component replaced by `f(v.z)`.\n   *\n   * @param v - The vector to update.\n   * @param f - The function to apply to the z component.\n   * @returns A new `Vector3` with the updated z.\n   * @since 2.0.0\n   */\n  (v: Vector3, f: (z: number) => number): Vector3\n  /**\n   * Returns a new `Vector3` with the z component replaced by `f(v.z)`.\n   *\n   * @param f - The function to apply to the z component.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (f: (z: number) => number): (v: Vector3) => Vector3\n} = internal.mapZ\n\n/**\n * Gets the radius of a `Vector3`.\n *\n * @param v - The vector of which to get the radius.\n * @returns The radius of the vector.\n * @since 1.0.0\n */\nexport const getR: (v: Vector3) => number = magnitude\n\nexport const setR: {\n  /**\n   * Sets the radius of a `Vector3`.\n   *\n   * @param v - The vector of which to set the radius.\n   * @param r - The new radius.\n   * @returns A new `Vector3` instance with the updated radius.\n   * @since 1.0.0\n   */\n  (v: Vector3, r: number): Vector3\n  /**\n   * Sets the radius of a `Vector3`.\n   *\n   * @param r - The new radius.\n   * @returns A function that takes the vector and returns the updated vector.\n   * @since 1.0.0\n   */\n  (r: number): (v: Vector3) => Vector3\n} = internal.setR\n\nexport const mapR: {\n  /**\n   * Returns a new `Vector3` with the radius replaced by `f(magnitude(v))`,\n   * preserving direction.\n   *\n   * @param v - The vector to update.\n   * @param f - The function to apply to the radius.\n   * @returns A new `Vector3` with the updated radius.\n   * @since 2.0.0\n   */\n  (v: Vector3, f: (r: number) => number): Vector3\n  /**\n   * Returns a new `Vector3` with the radius replaced by `f(magnitude(v))`,\n   * preserving direction.\n   *\n   * @param f - The function to apply to the radius.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (f: (r: number) => number): (v: Vector3) => Vector3\n} = internal.mapR\n\n/**\n * Gets the polar angle (theta) of a `Vector3`.\n *\n * @param v - The vector of which to get the polar angle.\n * @returns The polar angle of the vector.\n * @since 1.0.0\n */\nexport const getTheta: (v: Vector3) => number = internal.getTheta\n\nexport const setTheta: {\n  /**\n   * Sets the polar angle (theta) of a `Vector3`.\n   *\n   * @param v - The vector of which to set the polar angle.\n   * @param theta - The new polar angle.\n   * @returns A new `Vector3` instance with the updated polar angle.\n   * @since 1.0.0\n   */\n  (v: Vector3, theta: number): Vector3\n  /**\n   * Sets the polar angle (theta) of a `Vector3`.\n   *\n   * @param theta - The new polar angle.\n   * @returns A function that takes the vector and returns the updated vector.\n   * @since 1.0.0\n   */\n  (theta: number): (v: Vector3) => Vector3\n} = internal.setTheta\n\nexport const mapTheta: {\n  /**\n   * Returns a new `Vector3` with the polar angle replaced by\n   * `f(getTheta(v))`.\n   *\n   * @param v - The vector to update.\n   * @param f - The function to apply to the polar angle (in radians).\n   * @returns A new `Vector3` with the updated polar angle.\n   * @since 2.0.0\n   */\n  (v: Vector3, f: (theta: number) => number): Vector3\n  /**\n   * Returns a new `Vector3` with the polar angle replaced by\n   * `f(getTheta(v))`.\n   *\n   * @param f - The function to apply to the polar angle (in radians).\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (f: (theta: number) => number): (v: Vector3) => Vector3\n} = internal.mapTheta\n\n/**\n * Gets the azimuthal angle (phi) of a `Vector3`.\n *\n * @param v - The vector of which to get the azimuthal angle.\n * @returns The azimuthal angle of the vector.\n * @since 1.0.0\n */\nexport const getPhi: (v: Vector3) => number = internal.getPhi\n\nexport const setPhi: {\n  /**\n   * Sets the azimuthal angle (phi) of a `Vector3`.\n   *\n   * @param v - The vector of which to set the azimuthal angle.\n   * @param phi - The new azimuthal angle.\n   * @returns A new `Vector3` instance with the updated azimuthal angle.\n   * @since 1.0.0\n   */\n  (v: Vector3, phi: number): Vector3\n  /**\n   * Sets the azimuthal angle (phi) of a `Vector3`.\n   *\n   * @param phi - The new azimuthal angle.\n   * @returns A function that takes the vector and returns the updated vector.\n   * @since 1.0.0\n   */\n  (phi: number): (v: Vector3) => Vector3\n} = internal.setPhi\n\nexport const mapPhi: {\n  /**\n   * Returns a new `Vector3` with the azimuthal angle replaced by\n   * `f(getPhi(v))`.\n   *\n   * @param v - The vector to update.\n   * @param f - The function to apply to the azimuthal angle (in radians).\n   * @returns A new `Vector3` with the updated azimuthal angle.\n   * @since 2.0.0\n   */\n  (v: Vector3, f: (phi: number) => number): Vector3\n  /**\n   * Returns a new `Vector3` with the azimuthal angle replaced by\n   * `f(getPhi(v))`.\n   *\n   * @param f - The function to apply to the azimuthal angle (in radians).\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (f: (phi: number) => number): (v: Vector3) => Vector3\n} = internal.mapPhi\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,YAA0CA;AAEvD,MAAa,SAoBTC;AAEJ,MAAa,OA4BTC;;;;;;;;;AAUJ,MAAa,YAA+DC;;;;;;;;;;;AAY5E,MAAa,YAGsCC;;;;;;;;;;AAWnD,MAAa,gBACXC;;;;;;;;AASF,MAAa,YAAyCC;;;;;;;;;AAUtD,MAAa,SAAsC;;;;;;;;AASnD,MAAa,YAA0CC;AAEvD,MAAa,MAkBTC;AAEJ,MAAa,QAkBTC;;;;;;;;AASJ,MAAa,aAAuDC;;;;;;;;AASpE,MAAa,UAAmCC;;;;;;AAOhD,MAAa,OAAO,KAAK,EAAE;;;;;;AAO3B,MAAa,OAAO,KAAK,EAAE;;;;;;AAO3B,MAAa,QAAQ,KAAK,GAAG,GAAG,EAAE;;;;;;AAOlC,MAAa,QAAQ,KAAK,GAAG,GAAG,EAAE;;;;;;AAOlC,MAAa,QAAQ,KAAK,GAAG,GAAG,EAAE;AAElC,MAAa,MAkBTC;AAEJ,MAAa,WAkBTC;AAEJ,MAAa,WAsBTC;AAEJ,MAAa,QAkBTC;;;;;;;;AASJ,MAAa,OAA+BC;AAE5C,MAAa,OAkBTC;AAEJ,MAAa,OAkBTC;;;;;;;;AASJ,MAAa,OAA+BC;AAE5C,MAAa,OAkBTC;AAEJ,MAAa,OAkBTC;;;;;;;;AASJ,MAAa,OAA+BC;AAE5C,MAAa,OAkBTC;AAEJ,MAAa,OAkBTC;;;;;;;;AASJ,MAAa,OAA+B;AAE5C,MAAa,OAkBTC;AAEJ,MAAa,OAoBTC;;;;;;;;AASJ,MAAa,WAAmCC;AAEhD,MAAa,WAkBTC;AAEJ,MAAa,WAoBTC;;;;;;;;AASJ,MAAa,SAAiCC;AAE9C,MAAa,SAkBTC;AAEJ,MAAa,SAoBTC"}