Vector3d

class Vector3d

a generic 3D Vector Object

Constructor


new Vector3d(x: number, y: number, z: number) → {}
Parameters:
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

Public Properties


x vector3.js:25
x: number

number

x value of the vector

y vector3.js:31
y: number

number

y value of the vector

z vector3.js:37
z: number

number

z value of the vector

Public Methods


abs vector3.js:153
abs() → {Vector3d}

Update this vector values to absolute values

Returns:
Type Description
Vector3d

Reference to this object for method chaining

add vector3.js:90
add(v: Vector2d | Vector3d) → {Vector3d}

Add the passed vector to this vector

Parameters:
Name Type Description
v Vector2d | Vector3d
Returns:
Type Description
Vector3d

Reference to this object for method chaining

angle vector3.js:414
angle(v: Vector2d | Vector3d) → {number}

return the angle between this vector and the passed one

Parameters:
Name Type Description
v Vector2d | Vector3d
Returns:
Type Description
number

angle in radians

ceil vector3.js:217
ceil() → {Vector3d}

Ceil the vector values

Returns:
Type Description
Vector3d

new me.Vector3d

ceilSelf vector3.js:225
ceilSelf() → {Vector3d}

Ceil this vector values

Returns:
Type Description
Vector3d

Reference to this object for method chaining

clamp vector3.js:161
clamp(low: number, high: number) → {Vector3d}

Clamp the vector value within the specified value range

Parameters:
Name Type Description
low number
high number
Returns:
Type Description
Vector3d

new me.Vector3d

clampSelf vector3.js:171
clampSelf(low: number, high: number) → {Vector3d}

Clamp this vector value within the specified value range

Parameters:
Name Type Description
low number
high number
Returns:
Type Description
Vector3d

Reference to this object for method chaining

clone vector3.js:444
clone() → {Vector3d}

return a clone copy of this vector

Returns:
Type Description
Vector3d

new me.Vector3d

copy vector3.js:249
copy(v: Vector2d | Vector3d) → {Vector3d}

Copy the components of the given vector into this one

Parameters:
Name Type Description
v Vector2d | Vector3d
Returns:
Type Description
Vector3d

Reference to this object for method chaining

cross vector3.js:333
cross(v: Vector3d) → {Vector3d}

calculate the cross product of this vector and the passed one

Parameters:
Name Type Description
v Vector3d
Returns:
Type Description
Vector3d

Reference to this object for method chaining

distance vector3.js:402
distance(v: Vector2d | Vector3d) → {number}

return the distance between this vector and the passed one

Parameters:
Name Type Description
v Vector2d | Vector3d
Returns:
Type Description
number
div vector3.js:144
div(n: number) → {Vector3d}

Divide this vector values by the passed value

Parameters:
Name Type Description
n number

the value to divide the vector by

Returns:
Type Description
Vector3d

Reference to this object for method chaining

dot vector3.js:324
dot(v: Vector2d | Vector3d) → {number}

return the dot product of this vector and the passed one

Parameters:
Name Type Description
v Vector2d | Vector3d
Returns:
Type Description
number

The dot product.

equals vector3.js:258
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

Parameters:
Name Type Attributes Description
x number | Vector2d | ObservableVector2d | Vector3d | ObservableVector3d
y number

<optional>

z number

<optional>

Returns:
Type Description
boolean
floor vector3.js:201
floor() → {Vector3d}

Floor the vector values

Returns:
Type Description
Vector3d

new me.Vector3d

floorSelf vector3.js:209
floorSelf() → {Vector3d}

Floor this vector values

Returns:
Type Description
Vector3d

Reference to this object for method chaining

length vector3.js:357
length() → {number}

return the length (magnitude) of this vector

Returns:
Type Description
number

the length of this vector

length2 vector3.js:349
length2() → {number}

return the square length of this vector

Returns:
Type Description
number

The length^2 of this vector.

lerp vector3.js:365
lerp(v: Vector3d, alpha: number) → {Vector3d}

Linearly interpolate between this vector and the given one.

Parameters:
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).

Returns:
Type Description
Vector3d

Reference to this object for method chaining

maxV vector3.js:191
maxV(v: Vector2d | Vector3d) → {Vector3d}

Update this vector with the maximum value between this and the passed vector

Parameters:
Name Type Description
v Vector2d | Vector3d
Returns:
Type Description
Vector3d

Reference to this object for method chaining

minV vector3.js:181
minV(v: Vector2d | Vector3d) → {Vector3d}

Update this vector with the minimum value between this and the passed vector

Parameters:
Name Type Description
v Vector2d | Vector3d
Returns:
Type Description
Vector3d

Reference to this object for method chaining

moveTowards vector3.js:378
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.

Parameters:
Name Type Description
target Vector2d | Vector3d
step number

the maximum step per iteration (Negative values will push the vector away from the target)

Returns:
Type Description
Vector3d

Reference to this object for method chaining

negate vector3.js:233
negate() → {Vector3d}

Negate the vector values

Returns:
Type Description
Vector3d

new me.Vector3d

negateSelf vector3.js:241
negateSelf() → {Vector3d}

Negate this vector values

Returns:
Type Description
Vector3d

Reference to this object for method chaining

normalize vector3.js:282
normalize() → {Vector3d}

normalize this vector (scale the vector so that its magnitude is 1)

Returns:
Type Description
Vector3d

Reference to this object for method chaining

perp vector3.js:290
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)

Returns:
Type Description
Vector3d

Reference to this object for method chaining

project vector3.js:423
project(v: Vector2d | Vector3d) → {Vector3d}

project this vector on to another vector.

Parameters:
Name Type Description
v Vector2d | Vector3d

The vector to project onto.

Returns:
Type Description
Vector3d

Reference to this object for method chaining

projectN vector3.js:433
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.

Parameters:
Name Type Description
v Vector2d | Vector3d

The unit vector to project onto.

Returns:
Type Description
Vector3d

Reference to this object for method chaining

rotate vector3.js:299
rotate(angle: number, v: Vector2d | ObservableVector2d) → {Vector3d}

Rotate this vector (counter-clockwise) by the specified angle (in radians) around the z axis

Parameters:
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)

Returns:
Type Description
Vector3d

Reference to this object for method chaining

scale vector3.js:108
scale(x: number, y: number, z: number) → {Vector3d}

Multiply this vector values by the given scalar

Parameters:
Name Type Attributes Default Description
x number
y number

<optional>

x
z number

<optional>

1
Returns:
Type Description
Vector3d

Reference to this object for method chaining

scaleV vector3.js:119
scaleV(v: Vector2d | Vector3d) → {Vector3d}

Multiply this vector values by the passed vector

Parameters:
Name Type Description
v Vector2d | Vector3d
Returns:
Type Description
Vector3d

Reference to this object for method chaining

set vector3.js:57
set(x: number, y: number, z: number) → {Vector3d}

set the Vector x and y properties to the given values

Parameters:
Name Type Attributes Default Description
x number
y number
z number

<optional>

0
Returns:
Type Description
Vector3d

Reference to this object for method chaining

setV vector3.js:81
setV(v: Vector2d | Vector3d) → {Vector3d}

set the Vector x and y properties using the passed vector

Parameters:
Name Type Description
v Vector2d | Vector3d
Returns:
Type Description
Vector3d

Reference to this object for method chaining

setZero vector3.js:73
setZero() → {Vector3d}

set the Vector x and y properties to 0

Returns:
Type Description
Vector3d

Reference to this object for method chaining

sub vector3.js:99
sub(v: Vector2d | Vector3d) → {Vector3d}

Substract the passed vector to this vector

Parameters:
Name Type Description
v Vector2d | Vector3d
Returns:
Type Description
Vector3d

Reference to this object for method chaining

to2d vector3.js:136
to2d() → {Vector3d}

Convert this vector into 2d coordinate space

Returns:
Type Description
Vector3d

Reference to this object for method chaining

toIso vector3.js:128
toIso() → {Vector3d}

Convert this vector into isometric coordinate space

Returns:
Type Description
Vector3d

Reference to this object for method chaining

toString vector3.js:452
toString() → {string}

convert the object to a string representation

Returns:
Type Description
string

Powered by webdoc!