Class: DefVector

algeobra~DefVector(params)

Definition of a vector that can be constructed a number of ways A vector consists of x and y coordinates specifying its direction and length and a reference point to which it is attached to. While a mathematical vector is of course not bound to a specific point, this makes working with and displaying vectors easier

Constructor

new DefVector(params)

Constructor sets default values
Parameters:
Name Type Description
params Object
Properties
Name Type Description
x Number The default x coordinate
y Number The default y coordinate
ref Object The point to which this vector is attached to
normalize Boolean Whether or not this vector should be normalized
Source:

Methods

compute(createInfo) → {Object}

Computes the value of this definition
Parameters:
Name Type Description
createInfo CreateInfo
Source:
Returns:
The computed vector with type TYPE_VECTOR
Type
Object

(static) fromCoordinates(params) → {CreateInfo}

Creates a new vector from individual values
Parameters:
Name Type Description
params Object
Properties
Name Type Attributes Description
x Number | Object <optional>
Either the index or value of a TYPE_NUMBER. The x coordinate
y Number | Object <optional>
Either the index or value of a TYPE_NUMBER. The y coordinate
refX Number | Object <optional>
Either the index or value of a TYPE_NUMBER. The reference x coordinate
refY Number | Object <optional>
Either the index or value of a TYPE_NUMBER. The reference y coordinate
normalize Number | Object <optional>
Either the index or value of a TYPE_BOOLEAN. Whether the vector should be normalized
Source:
Returns:
The creation info
Type
CreateInfo

(static) fromLineSegment(line, normalizeopt) → {CreateInfo}

Creates a new vector from a line segment The vector will use the first line point as a reference and point to the second point
Parameters:
Name Type Attributes Description
line Number | Object Either the index or value of a TYPE_LINE. The line
normalize Number | Object <optional>
Either the index or value of a TYPE_BOOLEAN. Whether the vector should be normalized
Source:
Returns:
The creation info
Type
CreateInfo

(static) fromPoints(p0, p1, normalizeopt) → {CreateInfo}

Creates a new vector from two points The vector will use the first point as a reference and point to the second point
Parameters:
Name Type Attributes Description
p0 Number | Object Either the index or value of a TYPE_POINT. The first point
p1 Number | Object Either the index or value of a TYPE_POINT. The second point
normalize Number | Object <optional>
Either the index or value of a TYPE_BOOLEAN. Whether the vector should be normalized
Source:
Returns:
The creation info
Type
CreateInfo

(static) fromPolar(params) → {CreateInfo}

Creates a new vector from polar coordinates
Parameters:
Name Type Description
params Object
Properties
Name Type Attributes Description
polar Number | Object Either the index or value of a TYPE_POLAR. The polar coordinate
ref Number | Object <optional>
Either the index or value of a TYPE_POINT. The reference point
normalize Number | Object <optional>
Either the index or value of a TYPE_BOOLEAN. Whether the vector should be normalized
Source:
Returns:
The creation info
Type
CreateInfo

(static) fromPosition(params) → {CreateInfo}

Creates a new vector from the position vector of a point.
Parameters:
Name Type Description
params Object
Properties
Name Type Attributes Description
p Number | Object <optional>
Either the index or value of a TYPE_POINT. The position
normalize Number | Object <optional>
Either the index or value of a TYPE_BOOLEAN. Whether the vector should be normalized
Source:
Returns:
The creation info
Type
CreateInfo

(static) fromRefVector(params) → {CreateInfo}

Creates a new vector from another vector and reference position. If only a vector and no reference is given, the other vector's reference is used
Parameters:
Name Type Description
params Object
Properties
Name Type Attributes Description
ref Number | Object <optional>
Either the index or value of a TYPE_POINT. The reference point
v Number | Object <optional>
Either the index or value of a TYPE_VECTOR. The vector
normalize Number | Object <optional>
Either the index or value of a TYPE_BOOLEAN. Whether the vector should be normalized
Source:
Returns:
The creation info
Type
CreateInfo