Interface: vector2d

syngen.utility.vector2d

Provides an interface for two-dimensional vectors with x-y coordinates.

Source:
See:

Members

x :Number

Position along the x-axis.

Type:
  • Number
Source:

y :Number

Position along the y-axis.

Type:
  • Number
Source:

Methods

(static) create(optionsopt) → {syngen.utility.vector2d}

Instantiates a new two-dimensional vector.

Parameters:
Name Type Attributes Default Description
options syngen.utility.vector2d | Object <optional>
{}
Properties
Name Type Attributes Default Description
x Number <optional>
0
y Number <optional>
0
Source:
Returns:
Type
syngen.utility.vector2d

(static) unitX() → {syngen.utility.vector2d}

Instantiates a unit vector along the x-axis.

Source:
Returns:
Type
syngen.utility.vector2d

(static) unitY() → {syngen.utility.vector2d}

Instantiates a unit vector along the y-axis.

Source:
Returns:
Type
syngen.utility.vector2d

add(vectoropt) → {syngen.utility.vector2d|Object}

Adds vector to this and returns their sum as a new instance.

Parameters:
Name Type Attributes Description
vector syngen.utility.vector2d | Object <optional>
Source:
Returns:
Type
syngen.utility.vector2d | Object

angle() → {Number}

Calculates the angle between this and the positive x-axis, in radians.

Source:
Returns:
Type
Number

clone() → {syngen.utility.vector2d}

Returns a new instance with the same properties.

Source:
Returns:
Type
syngen.utility.vector2d

crossProduct(vectoropt) → {Number}

Calculates the cross product with vector. This operation is noncommunicative.

Parameters:
Name Type Attributes Description
vector syngen.utility.vector2d | Object <optional>
Source:
Returns:
Type
Number

distance(vectoropt) → {Number}

Calculates the Euclidean distance from vector.

Parameters:
Name Type Attributes Description
vector syngen.utility.vector2d | Object <optional>
Source:
Returns:
Type
Number

distance2(vectoropt) → {Number}

Calculates the squared Euclidean distance from vector.

Parameters:
Name Type Attributes Description
vector syngen.utility.vector2d | Object <optional>
Source:
Returns:
Type
Number

dotProduct(vectoropt) → {Number}

Calculates the dot product with vector.

Parameters:
Name Type Attributes Description
vector syngen.utility.vector2d | Object <optional>
Source:
Returns:
Type
Number

equals(vectoropt) → {Boolean}

Returns whether this is equal to vector.

Parameters:
Name Type Attributes Description
vector syngen.utility.vector2d | Object <optional>
Source:
Returns:
Type
Boolean

inverse() → {syngen.utility.vector2d}

Returns the inverse vector as a new instance.

Source:
Returns:
Type
syngen.utility.vector2d

isZero() → {Boolean}

Returns whether this represents the origin.

Source:
Returns:
Type
Boolean

normalize() → {syngen.utility.vector2d}

Scales this by its distance to return a unit vector as a new instance.

Source:
Returns:
Type
syngen.utility.vector2d

rotate(angleopt) → {syngen.utility.vector2d}

Rotates by angle, in radians, and returns it as a new instance.

Parameters:
Name Type Attributes Default Description
angle Number <optional>
0
Source:
Returns:
Type
syngen.utility.vector2d

scale(scalaropt) → {syngen.utility.vector2d}

Multiplies this by scalar and returns it as a new instance.

Parameters:
Name Type Attributes Default Description
scalar Number <optional>
0
Source:
Returns:
Type
syngen.utility.vector2d

set(optionsopt)

Sets all properties with options.

Parameters:
Name Type Attributes Description
options syngen.utility.vector2d | Object <optional>
Properties
Name Type Attributes Default Description
x Number <optional>
0
y Number <optional>
0
Source:

subtract(vectoropt) → {syngen.utility.vector2d|Object}

Subtracts vector from this and returns their difference as a new instance.

Parameters:
Name Type Attributes Description
vector syngen.utility.vector2d | Object <optional>
Source:
Returns:
Type
syngen.utility.vector2d | Object

subtractRadius(radiusopt) → {syngen.utility.vector2d}

Subtracts a circular radius from this and returns it as a new instance.

Parameters:
Name Type Attributes Default Description
radius Number <optional>
0
Source:
Returns:
Type
syngen.utility.vector2d