Class

DuVector

DuVector(components)

A class to manipulate vectors
Constructor

# new DuVector(components)

Constructs a new Vector
Parameters:
Name Type Description
components Array.<Number> The components of the vector, one number per dimension

View Source DuAEF.jsxinc, line 7422

Methods

# static fromPoints(pointA, pointB) → {DuVector}

Creates a vector from two points
Parameters:
Name Type Description
pointA Array.<Number> The origin of the vector
pointB Array.<Number> The end of the vector

View Source DuAEF.jsxinc, line 7438

DuVector

# static unit(axis, dimensions) → {DuVector}

Creates a unit vector
Parameters:
Name Type Description
axis Number The unit axis
dimensions Number The number of dimensions

View Source DuAEF.jsxinc, line 7456

DuVector

# add(other) → {DuVector}

Addition
Parameters:
Name Type Description
other DuVector The vector to add

View Source DuAEF.jsxinc, line 7468

The result
DuVector

# angle(other) → {Number}

Gets the angle between the two vectors
Parameters:
Name Type Description
other DuVector

View Source DuAEF.jsxinc, line 7605

The angle in degrees
Number

# cross(other) → {DuVector}

Cross Product
Parameters:
Name Type Description
other DuVector

View Source DuAEF.jsxinc, line 7586

DuVector

# dot(other) → {Number}

Dot Product
Parameters:
Name Type Description
other DuVector The other vector

View Source DuAEF.jsxinc, line 7528

Number

# hasOppositeDirection(other) → {Boolean}

Checks if the two vectors have an opposite direction
Parameters:
Name Type Description
other DuVector

View Source DuAEF.jsxinc, line 7564

Boolean

# hasSameDirection(other) → {Boolean}

Checks if the two vectors have the same direction
Parameters:
Name Type Description
other DuVector

View Source DuAEF.jsxinc, line 7553

Boolean

# isPerpendicular(other) → {Boolean}

Checks if the two vectors are perpendicular
Parameters:
Name Type Description
other DuVector

View Source DuAEF.jsxinc, line 7575

Boolean

# length() → {Number}

+ The length of the vector

View Source DuAEF.jsxinc, line 7519

The length
Number

# negate() → {DuVector}

Creates the same vector in the opposite direction (scale -1)

View Source DuAEF.jsxinc, line 7617

DuVector

# normalize() → {DuVector}

Create a normalized vector (with length equal to 1)

View Source DuAEF.jsxinc, line 7544

The normalized vector
DuVector

# orientation2D(other) → {Number}

Checks the orientation of the angle between 2D vectors
Parameters:
Name Type Description
other DuVector

View Source DuAEF.jsxinc, line 7654

1: counter-clockwiser, -1: clockwise, 0: aligned
Number

# orientedAngle(other) → {Number}

Gets the angle between the two 2D vectors
Parameters:
Name Type Description
other DuVector

View Source DuAEF.jsxinc, line 7666

Number

# projectOn(other) → {DuVector}

Projects the vector on another vector
Parameters:
Name Type Description
other DuVector

View Source DuAEF.jsxinc, line 7626

DuVector

# scale(factor) → {DuVector}

Scale
Parameters:
Name Type Description
factor Number The scale factor

View Source DuAEF.jsxinc, line 7504

The result
DuVector

# setLength(newLength) → {DuVector}

Sets a new length for the vector
Parameters:
Name Type Description
newLength Number

View Source DuAEF.jsxinc, line 7636

DuVector

# subtract(other) → {DuVector}

Subtraction
Parameters:
Name Type Description
other DuVector The vector to subtract

View Source DuAEF.jsxinc, line 7486

The result
DuVector