Constructor
new Vector(parametersopt)
Creates a new Vector
instance.
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
parameters | Object | <optional> | The parameters for the vector. Properties
|
- Source
Members
NEGATIVE_X
The NEGATIVE_X vector is a unit vector pointing in the negative x direction.
- Source
NEGATIVE_Y
The NEGATIVE_Y vector is a unit vector pointing in the negative y direction.
- Source
NEGATIVE_Z
The NEGATIVE_Z vector is a unit vector pointing in the negative z direction.
- Source
X
The X vector is a unit vector pointing in the positive x direction.
- Source
Y
The Y vector is a unit vector pointing in the positive y direction.
- Source
Z
The Z vector is a unit vector pointing in the positive z direction.
- Source
ZERO
The ZERO vector is an empty vector.
- Source
length
Gets the length (magnitude) of this vector.
- Source
x
Gets the X component of this vector.
- Source
x
Sets the X component of this vector.
- Source
y
Gets the Y component of this vector.
- Source
y
Sets the Y component of this vector.
- Source
z
Gets the Z component of this vector.
- Source
z
Sets the Z component of this vector.
- Source
Methods
add(other) → {Vector}
Adds another vector to this vector.
Name | Type | Description |
---|---|---|
other | Vector | The vector to add. |
- Source
A new Vector
representing the result.
- Type:
- Vector
angle(other) → {number}
Computes the angle between this vector and another vector.
Name | Type | Description |
---|---|---|
other | Vector | The other vector. |
- Source
The angle between the vectors in radians.
- Type:
- number
cross(other) → {Vector}
Computes the cross product of this vector with another vector.
Name | Type | Description |
---|---|---|
other | Vector | The other vector. |
- Source
A new Vector
representing the result.
- Type:
- Vector
distance(other) → {number}
Computes the distance between this vector and another vector.
Name | Type | Description |
---|---|---|
other | Vector | The other vector. |
- Source
The distance between the vectors.
- Type:
- number
divide(scalar) → {Vector}
Divides this vector by a scalar.
Name | Type | Description |
---|---|---|
scalar | number | The scalar to divide by. |
- Source
A new Vector
representing the result.
- Type:
- Vector
dot(other) → {number}
Computes the dot product of this vector with another vector.
Name | Type | Description |
---|---|---|
other | Vector | The other vector. |
- Source
The dot product of the two vectors.
- Type:
- number
isEqual(other) → {boolean}
Checks if this vector is equal to another vector.
Name | Type | Description |
---|---|---|
other | Vector | The other vector. |
- Source
true
if the vectors are equal, false
otherwise.
- Type:
- boolean
isParallel(other) → {boolean}
Checks if this vector is parallel to another vector.
Name | Type | Description |
---|---|---|
other | Vector | The other vector. |
- Source
true
if the vectors are parallel, false
otherwise.
- Type:
- boolean
isPerpendicular(other) → {boolean}
Checks if this vector is perpendicular (normal) to another vector.
Name | Type | Description |
---|---|---|
other | Vector | The other vector. |
- Source
true
if the vectors are perpendicular, false
otherwise.
- Type:
- boolean
mirror(plane) → {Vector}
Mirrors this vector across a specified plane.
Name | Type | Description |
---|---|---|
plane | Plane | The plane to mirror across. |
- Source
A new Vector
representing the mirrored result.
- Type:
- Vector
multiply(scalar) → {Vector}
Multiplies this vector by a scalar.
Name | Type | Description |
---|---|---|
scalar | number | The scalar to multiply by. |
- Source
A new Vector
representing the result.
- Type:
- Vector
normalize() → {Vector}
Normalizes this vector to have a length of 1.
- Source
A new Vector
representing the result.
- Type:
- Vector
rotate(parameters) → {Vector}
Rotates this vector around a specified axis by a given angle.
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
parameters | Object | Rotation parameters. Properties
|
- Source
A new Vector
representing the result.
- Type:
- Vector
scale(scalar) → {Vector}
Scales this vector by a scalar.
Name | Type | Description |
---|---|---|
scalar | number | The scaling factor. |
- Source
A new Vector
representing the result.
- Type:
- Vector
subtract(other) → {Vector}
Subtracts another vector from this vector.
Name | Type | Description |
---|---|---|
other | Vector | The vector to subtract. |
- Source
A new Vector
representing the result.
- Type:
- Vector