Class: Vector

Class representing a vector in 3D space.

Implements

  • Vector

Constructors

new Vector()

new Vector(vector): Vector

Constructs a new Vector object.

Parameters

vector: Point = ...

The vector to initialize the object with. Defaults to [0, 0, 0].

Returns

Vector

Properties

oc

protected oc: OpenCascadeInstance


w

w: number

Implementation of

IVector.w

Accessors

length

get length(): number

Returns the length of the vector.

Returns

number

The length of the vector.

Implementation of

IVector.length


type

get type(): Type

Gets the type of the vector.

Returns

Type

The type of the vector.

Implementation of

IVector.type


vector

get vector(): gp_Vec

Gets the vector.

set vector(vector): void

Sets the vector for this object.

Parameters

vector: gp_Vec

The vector to set.

Returns

gp_Vec

The vector.

Implementation of

IVector.vector


x

get x(): number

Gets the x coordinate of the vector.

Returns

number

The x coordinate of the vector.

Implementation of

IVector.x


y

get y(): number

Gets the y coordinate of the vector.

Returns

number

The y coordinate of the vector.

Implementation of

IVector.y


z

get z(): number

Gets the z coordinate of the vector.

Returns

number

The z coordinate of the vector.

Implementation of

IVector.z

Methods

add()

add(v): Vector

Adds a vector to the current vector.

Parameters

v: Vector

The vector to be added.

Returns

Vector

A new vector that is the result of the addition.

Implementation of

IVector.add


copy()

copy(): Vector

Creates a copy of the vector.

Returns

Vector

A new instance of the Vector class with the same values as the original vector.

Implementation of

IVector.copy


cross()

cross(v): Vector

Calculates the cross product of this vector and the given vector.

Parameters

v: Vector

The vector to calculate the cross product with.

Returns

Vector

The resulting vector from the cross product operation.

Implementation of

IVector.cross


delete()

delete(): void

Deletes the vector.

Returns

void

Implementation of

IVector.delete


distance()

distance(second): number

Calculates the distance between two vectors.

Parameters

second: Vector

The second vector to calculate the distance to.

Returns

number

The distance between the two vectors.

Implementation of

IVector.distance


dot()

dot(v): number

Calculates the dot product between this vector and the given vector.

Parameters

v: Vector

The vector to calculate the dot product with.

Returns

number

The dot product of the two vectors.

Implementation of

IVector.dot


dump()

dump(): string

Returns a string representation of the vector.

Returns

string

The string representation of the vector.

Implementation of

IVector.dump


equals()

equals(other): boolean

Checks if this vector is equal to the given vector.

Parameters

other: Vector

The vector to compare with.

Returns

boolean

True if the vectors are equal, false otherwise.

Implementation of

IVector.equals


getAngle()

getAngle(v): number

Calculates the angle between two vectors.

Parameters

v: Vector

The vector to calculate the angle with.

Returns

number

The angle between the two vectors in radians.

Implementation of

IVector.getAngle


getCenter()

getCenter(): Vector

Returns the center vector.

Returns

Vector

The center vector.

Implementation of

IVector.getCenter


mirrorByCurve()

mirrorByCurve(curve): Vector

Mirrors the vector by a given curve.

Parameters

curve: Curve

The curve to mirror the vector by.

Returns

Vector

The mirrored vector.

Implementation of

IVector.mirrorByCurve


multiply()

multiply(scale): Vector

Multiplies the vector by the given scale.

Parameters

scale: number

The scale factor to multiply the vector by.

Returns

Vector

A new Vector object representing the result of the multiplication.

Implementation of

IVector.multiply


normalize()

normalize(): Vector

Normalizes the vector.

Returns

Vector

The normalized vector.

Implementation of

IVector.normalize


normalized()

normalized(): Vector

Returns a new Vector object that represents the normalized version of this vector. The normalized vector has the same direction as the original vector, but its length is 1.

Returns

Vector

A new Vector object representing the normalized vector.

Implementation of

IVector.normalized


projectToPlane()

projectToPlane(plane): Vector

Projects the vector onto a plane.

Parameters

plane: Plane

The plane onto which the vector will be projected.

Returns

Vector

The projected vector.


reverse()

reverse(): Vector

Reverses the vector in place.

Returns

Vector

The reversed vector.

Implementation of

IVector.reverse


reversed()

reversed(): Vector

Reverses the vector.

Returns

Vector

The reversed vector.

Implementation of

IVector.reversed


rotate()

rotate(angle, center, direction): Vector

Rotates the vector by the specified angle around the given center and direction.

Parameters

angle: number

The angle (in radians) by which to rotate the vector.

center: Point = ...

The center point around which to rotate the vector. Defaults to [0, 0, 0].

direction: Point = ...

The direction vector around which to rotate the vector. Defaults to [0, 0, 1].

Returns

Vector

The rotated vector.

Implementation of

IVector.rotate


rotated()

rotated(angle, center, direction): Vector

Rotates the vector by the specified angle around the given center and direction.

Parameters

angle: number

The angle (in radians) by which to rotate the vector.

center: Point = ...

The center point around which to rotate the vector. Defaults to [0, 0, 0].

direction: Point = ...

The direction vector around which to rotate the vector. Defaults to [0, 0, 1].

Returns

Vector

A new Vector object representing the rotated vector.

Implementation of

IVector.rotated


setPlane()

setPlane(localPlane, globalPlane?): Vector

Sets the plane of the vector.

Parameters

localPlane: Plane

The local plane.

globalPlane?: Plane

The global plane.

Returns

Vector

A new Vector object with the transformed vector.

Implementation of

IVector.setPlane


sub()

sub(v): Vector

Subtracts the given vector from this vector.

Parameters

v: Vector

The vector to subtract.

Returns

Vector

A new vector representing the subtraction result.

Implementation of

IVector.sub


toDir()

toDir(): gp_Dir

Converts the vector to a direction.

Returns

gp_Dir

The direction representation of the vector.

Implementation of

IVector.toDir


toPnt()

toPnt(): gp_Pnt

Converts the vector to a point in 3D space.

Returns

gp_Pnt

The converted point.

Implementation of

IVector.toPnt


toTuple()

toTuple(): [number, number, number]

Converts the vector to a tuple representation.

Returns

[number, number, number]

The tuple representation of the vector as [x, y, z].

Implementation of

IVector.toTuple


toVec()

toVec(): gp_Vec

Converts the vector to a gp_Vec object.

Returns

gp_Vec

The converted gp_Vec object.

Implementation of

IVector.toVec


translate()

translate(vector): Vector

Translates the current vector by adding the given vector.

Parameters

vector: Vector

The vector to be added.

Returns

Vector

A new vector representing the result of the translation.

Implementation of

IVector.translate


by2Point()

static by2Point(start, end): Vector

Creates a new Vector by subtracting the coordinates of the end Vector from the coordinates of the start Vector.

Parameters

start: Vector

The start Vector.

end: Vector

The end Vector.

Returns

Vector

A new Vector representing the difference between the end and start Vectors.