@achirita/blox
Version:
A CAD library for building 3D models in the browser.
179 lines (178 loc) • 5.72 kB
TypeScript
export class Vector {
/**
* The ZERO vector is an empty vector.
* @static
*/
static ZERO: Vector;
/**
* The X vector is a unit vector pointing in the positive x direction.
* @static
*/
static X: Vector;
/**
* The NEGATIVE_X vector is a unit vector pointing in the negative x direction.
* @static
*/
static NEGATIVE_X: Vector;
/**
* The Y vector is a unit vector pointing in the positive y direction.
* @static
*/
static Y: Vector;
/**
* The NEGATIVE_Y vector is a unit vector pointing in the negative y direction.
* @static
*/
static NEGATIVE_Y: Vector;
/**
* The Z vector is a unit vector pointing in the positive z direction.
* @static
*/
static Z: Vector;
/**
* The NEGATIVE_Z vector is a unit vector pointing in the negative z direction.
* @static
*/
static NEGATIVE_Z: Vector;
/**
* Creates a new `Vector` instance.
* @param {Object} [parameters] - The parameters for the vector.
* @param {number} [parameters.x=0] - The X component of the vector.
* @param {number} [parameters.y=0] - The Y component of the vector.
* @param {number} [parameters.z=0] - The Z component of the vector.
*/
constructor({ x, y, z, wrapped }?: {
x?: number;
y?: number;
z?: number;
});
/**
* Returns the wrapped OpenCascade object.
* @private
*/
private get wrapped();
/**
* Sets the X component of this vector.
*/
set x(value: any);
/**
* Gets the X component of this vector.
*/
get x(): any;
/**
* Sets the Y component of this vector.
*/
set y(value: any);
/**
* Gets the Y component of this vector.
*/
get y(): any;
/**
* Sets the Z component of this vector.
*/
set z(value: any);
/**
* Gets the Z component of this vector.
*/
get z(): any;
/**
* Gets the length (magnitude) of this vector.
* @returns {number} The length of the vector.
*/
get length(): number;
/**
* Adds another vector to this vector.
* @param {Vector} other - The vector to add.
* @returns {Vector} A new `Vector` representing the result.
*/
add(other: Vector): Vector;
/**
* Subtracts another vector from this vector.
* @param {Vector} other - The vector to subtract.
* @returns {Vector} A new `Vector` representing the result.
*/
subtract(other: Vector): Vector;
/**
* Multiplies this vector by a scalar.
* @param {number} scalar - The scalar to multiply by.
* @returns {Vector} A new `Vector` representing the result.
*/
multiply(scalar: number): Vector;
/**
* Divides this vector by a scalar.
* @param {number} scalar - The scalar to divide by.
* @returns {Vector} A new `Vector` representing the result.
*/
divide(scalar: number): Vector;
/**
* Computes the cross product of this vector with another vector.
* @param {Vector} other - The other vector.
* @returns {Vector} A new `Vector` representing the result.
*/
cross(other: Vector): Vector;
/**
* Computes the dot product of this vector with another vector.
* @param {Vector} other - The other vector.
* @returns {number} The dot product of the two vectors.
*/
dot(other: Vector): number;
/**
* Rotates this vector around a specified axis by a given angle.
* @param {Object} parameters - Rotation parameters.
* @param {Axis} parameters.axis - The axis to rotate around.
* @param {number} parameters.angle - The rotation angle in radians.
* @returns {Vector} A new `Vector` representing the result.
*/
rotate({ axis, angle }: {
axis: Axis;
angle: number;
}): Vector;
/**
* Scales this vector by a scalar.
* @param {number} scalar - The scaling factor.
* @returns {Vector} A new `Vector` representing the result.
*/
scale(scalar: number): Vector;
/**
* Mirrors this vector across a specified plane.
* @param {Plane} plane - The plane to mirror across.
* @returns {Vector} A new `Vector` representing the mirrored result.
*/
mirror(plane: Plane): Vector;
/**
* Computes the distance between this vector and another vector.
* @param {Vector} other - The other vector.
* @returns {number} The distance between the vectors.
*/
distance(other: Vector): number;
/**
* Computes the angle between this vector and another vector.
* @param {Vector} other - The other vector.
* @returns {number} The angle between the vectors in radians.
*/
angle(other: Vector): number;
/**
* Normalizes this vector to have a length of 1.
* @returns {Vector} A new `Vector` representing the result.
*/
normalize(): Vector;
/**
* Checks if this vector is equal to another vector.
* @param {Vector} other - The other vector.
* @returns {boolean} `true` if the vectors are equal, `false` otherwise.
*/
isEqual(other: Vector): boolean;
/**
* Checks if this vector is perpendicular (normal) to another vector.
* @param {Vector} other - The other vector.
* @returns {boolean} `true` if the vectors are perpendicular, `false` otherwise.
*/
isPerpendicular(other: Vector): boolean;
/**
* Checks if this vector is parallel to another vector.
* @param {Vector} other - The other vector.
* @returns {boolean} `true` if the vectors are parallel, `false` otherwise.
*/
isParallel(other: Vector): boolean;
#private;
}