import { XYPoint } from "../utils/types.ts"; import { Vector2d } from "./vector2d.ts"; /** * a generic 3D Vector Object * @category Math */ export declare class Vector3d { x: number; y: number; z: number; /** * @param [x] - x value of the vector * @param [y] - y value of the vector * @param [z] - z value of the vector */ constructor(x?: number, y?: number, z?: number); onResetEvent(x?: number, y?: number, z?: number): void; /** * set the Vector x and y properties to the given values * @param x x component * @param y y component * @param [z] z component * @returns Reference to this object for method chaining */ set(x: number, y: number, z?: number | undefined): this; /** * set the Vector x and y properties to 0 * @returns Reference to this object for method chaining */ setZero(): this; /** * set the Vector x and y properties using the passed vector * @param v other vector * @returns Reference to this object for method chaining */ setV(v: Vector2d | Vector3d): this; /** * Add the passed vector to this vector * @param v other vector * @returns Reference to this object for method chaining */ add(v: Vector2d | Vector3d): this; /** * Subtract the passed vector from this vector * @param v other vector * @returns Reference to this object for method chaining */ sub(v: Vector2d | Vector3d): this; /** * Multiply this vector values by the given scalar * @param x x component * @param [y] y component * @param [z] z component * @returns Reference to this object for method chaining */ scale(x: number, y?: number, z?: number): this; /** * Multiply this vector values by the passed vector * @param v other vector * @returns Reference to this object for method chaining */ scaleV(v: Vector3d): this; /** * Convert this vector into isometric coordinate space * @returns Reference to this object for method chaining */ toIso(): this; /** * Convert this vector into 2d coordinate space * @returns Reference to this object for method chaining */ to2d(): this; /** * Divide this vector values by the passed value * @param n - the value to divide the vector by * @returns Reference to this object for method chaining */ div(n: number): this; /** * Update this vector values to absolute values * @returns Reference to this object for method chaining */ abs(): this; /** * Clamp the vector value within the specified value range * @param low lower bound * @param high upper bound * @returns new Vector3d */ clamp(low: number, high: number): Vector3d; /** * Clamp this vector value within the specified value range * @param low lower bound * @param high upper bound * @returns Reference to this object for method chaining */ clampSelf(low: number, high: number): this; /** * Update this vector with the minimum value between this and the passed vector * @param v other vector * @returns Reference to this object for method chaining */ minV(v: Vector2d | Vector3d): this; /** * Update this vector with the maximum value between this and the passed vector * @param v other vector * @returns Reference to this object for method chaining */ maxV(v: Vector2d | Vector3d): this; /** * Floor the vector values * @returns new Vector3d */ floor(): Vector3d; /** * Floor this vector values * @returns Reference to this object for method chaining */ floorSelf(): this; /** * Ceil the vector values * @returns new Vector3d */ ceil(): Vector3d; /** * Ceil this vector values * @returns Reference to this object for method chaining */ ceilSelf(): this; /** * Negate the vector values * @returns new Vector3d */ negate(): Vector3d; /** * Negate this vector values * @returns Reference to this object for method chaining */ negateSelf(): this; /** * Copy the components of the given vector into this one * @param v other vector * @returns Reference to this object for method chaining */ copy(v: Vector2d | Vector3d): this; /** * return true if this vector is equal to the given values or vector * @param args other vector or vector components * @returns true if both vectors are equal */ equals(...args: [number] | [Vector2d] | [Vector3d] | [number, number] | [number, number, number]): boolean; /** * normalize this vector (scale the vector so that its magnitude is 1) * @returns Reference to this object for method chaining */ normalize(): this; /** * change this vector to be perpendicular to what it was before.
* (Effectively rotates it 90 degrees in a clockwise direction around the z axis) * @returns Reference to this object for method chaining */ perp(): this; /** * Rotate this vector (counter-clockwise) by the specified angle (in radians) around the z axis * @param angle - The angle to rotate (in radians) * @param [v] - an optional point to rotate around * @returns Reference to this object for method chaining */ rotate(angle: number, v?: XYPoint | Vector3d): this; /** * return the dot product of this vector and the passed one * @param v other vector * @returns The dot product. */ dot(v: Vector2d | Vector3d): number; /** * calculate the cross product of this vector and the passed one * @param v other vector * @returns Reference to this object for method chaining */ cross(v: Vector3d): this; /** * return the square length of this vector * @returns The length^2 of this vector. */ length2(): number; /** * return the length (magnitude) of this vector * @returns the length of this vector */ length(): number; /** * Linearly interpolate between this vector and the given one. * @param v other vector * @param alpha - distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one). * @returns Reference to this object for method chaining */ lerp(v: Vector3d, alpha: number): this; /** * interpolate the position of this vector on the x and y axis towards the given one by the given maximum step. * @param target other vector * @param step - the maximum step per iteration (Negative values will push the vector away from the target) * @returns Reference to this object for method chaining */ moveTowards(target: Vector2d | Vector3d, step: number): Vector2d | Vector3d; /** * return the distance between this vector and the passed one * @param v other vector * @returns distance */ distance(v: Vector2d | Vector3d): number; /** * return the angle between this vector and the passed one * @param v other vector * @returns angle in radians */ angle(v: Vector2d | Vector3d): number; /** * project this vector on to another vector. * @param v - The vector to project onto. * @returns Reference to this object for method chaining */ project(v: Vector2d | Vector3d): this; /** * Project this vector onto a vector of unit length.
* This is slightly more efficient than `project` when dealing with unit vectors. * @param v - The unit vector to project onto. * @returns Reference to this object for method chaining */ projectN(v: Vector2d | Vector3d): this; /** * return a clone copy of this vector * @returns new Vector3d */ clone(): Vector3d; /** * convert the object to a string representation * @returns stringified representation */ toString(): `x:${number},y:${number},z:${number}`; } export declare const vector3dPool: import("../system/pool.ts").Pool; //# sourceMappingURL=vector3d.d.ts.map