Vector3d
class Vector3d
a generic 3D Vector Object
Constructor
new Vector3d(x: number, y: number, z: number) → {}
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x | number |
<optional> |
0 |
x value of the vector |
y | number |
<optional> |
0 |
y value of the vector |
z | number |
<optional> |
0 |
z value of the vector |
Summary
Methods from Vector3d
Public Properties
Public Methods
abs() → {Vector3d}
Update this vector values to absolute values
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
add(v: Vector2d | Vector3d) → {Vector3d}
Add the passed vector to this vector
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
angle(v: Vector2d | Vector3d) → {number}
return the angle between this vector and the passed one
Type | Description |
---|---|
number |
angle in radians |
ceil() → {Vector3d}
Ceil the vector values
Type | Description |
---|---|
Vector3d |
new me.Vector3d |
ceilSelf() → {Vector3d}
Ceil this vector values
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
clamp(low: number, high: number) → {Vector3d}
Clamp the vector value within the specified value range
Name | Type | Description |
---|---|---|
low | number | |
high | number |
Type | Description |
---|---|
Vector3d |
new me.Vector3d |
clampSelf(low: number, high: number) → {Vector3d}
Clamp this vector value within the specified value range
Name | Type | Description |
---|---|---|
low | number | |
high | number |
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
clone() → {Vector3d}
return a clone copy of this vector
Type | Description |
---|---|
Vector3d |
new me.Vector3d |
copy(v: Vector2d | Vector3d) → {Vector3d}
Copy the components of the given vector into this one
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
cross(v: Vector3d) → {Vector3d}
calculate the cross product of this vector and the passed one
Name | Type | Description |
---|---|---|
v | Vector3d |
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
distance(v: Vector2d | Vector3d) → {number}
return the distance between this vector and the passed one
Type | Description |
---|---|
number |
div(n: number) → {Vector3d}
Divide this vector values by the passed value
Name | Type | Description |
---|---|---|
n | number |
the value to divide the vector by |
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
dot(v: Vector2d | Vector3d) → {number}
return the dot product of this vector and the passed one
Type | Description |
---|---|
number |
The dot product. |
equals(x: number | Vector2d | ObservableVector2d | Vector3d | ObservableVector3d, y: number, z: number) → {boolean}
return true if this vector is equal to the given values or vector
Name | Type | Attributes | Description |
---|---|---|---|
x | number | Vector2d | ObservableVector2d | Vector3d | ObservableVector3d | ||
y | number |
<optional> |
|
z | number |
<optional> |
Type | Description |
---|---|
boolean |
floor() → {Vector3d}
Floor the vector values
Type | Description |
---|---|
Vector3d |
new me.Vector3d |
floorSelf() → {Vector3d}
Floor this vector values
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
length() → {number}
return the length (magnitude) of this vector
Type | Description |
---|---|
number |
the length of this vector |
length2() → {number}
return the square length of this vector
Type | Description |
---|---|
number |
The length^2 of this vector. |
lerp(v: Vector3d, alpha: number) → {Vector3d}
Linearly interpolate between this vector and the given one.
Name | Type | Description |
---|---|---|
v | Vector3d | |
alpha | number |
distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one). |
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
maxV(v: Vector2d | Vector3d) → {Vector3d}
Update this vector with the maximum value between this and the passed vector
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
minV(v: Vector2d | Vector3d) → {Vector3d}
Update this vector with the minimum value between this and the passed vector
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
moveTowards(target: Vector2d | Vector3d, step: number) → {Vector3d}
interpolate the position of this vector on the x and y axis towards the given one by the given maximum step.
Name | Type | Description |
---|---|---|
target | Vector2d | Vector3d | |
step | number |
the maximum step per iteration (Negative values will push the vector away from the target) |
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
negate() → {Vector3d}
Negate the vector values
Type | Description |
---|---|
Vector3d |
new me.Vector3d |
negateSelf() → {Vector3d}
Negate this vector values
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
normalize() → {Vector3d}
normalize this vector (scale the vector so that its magnitude is 1)
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
perp() → {Vector3d}
change this vector to be perpendicular to what it was before.
(Effectively rotates it 90 degrees in a clockwise direction around the z axis)
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
project(v: Vector2d | Vector3d) → {Vector3d}
project this vector on to another vector.
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
projectN(v: Vector2d | Vector3d) → {Vector3d}
Project this vector onto a vector of unit length.
This is slightly more efficient than project
when dealing with unit vectors.
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
rotate(angle: number, v: Vector2d | ObservableVector2d) → {Vector3d}
Rotate this vector (counter-clockwise) by the specified angle (in radians) around the z axis
Name | Type | Attributes | Description |
---|---|---|---|
angle | number |
The angle to rotate (in radians) |
|
v | Vector2d | ObservableVector2d |
<optional> |
an optional point to rotate around (on the same z axis) |
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
scale(x: number, y: number, z: number) → {Vector3d}
Multiply this vector values by the given scalar
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x | number | |||
y | number |
<optional> |
x | |
z | number |
<optional> |
1 |
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
scaleV(v: Vector2d | Vector3d) → {Vector3d}
Multiply this vector values by the passed vector
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
set(x: number, y: number, z: number) → {Vector3d}
set the Vector x and y properties to the given values
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x | number | |||
y | number | |||
z | number |
<optional> |
0 |
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
setV(v: Vector2d | Vector3d) → {Vector3d}
set the Vector x and y properties using the passed vector
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
setZero() → {Vector3d}
set the Vector x and y properties to 0
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
sub(v: Vector2d | Vector3d) → {Vector3d}
Substract the passed vector to this vector
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
to2d() → {Vector3d}
Convert this vector into 2d coordinate space
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
toIso() → {Vector3d}
Convert this vector into isometric coordinate space
Type | Description |
---|---|
Vector3d |
Reference to this object for method chaining |
toString() → {string}
convert the object to a string representation
Type | Description |
---|---|
string |