@svizzle/geometry/2DVector

Methods

(static) makeVectorFeatures(point) → {object}

Source:
Since:
  • 0.1.0

Calculates length and versor of a vector

Example
> makeVectorFeatures({x: 1, y: 1})
{
	length: 1.4142135623730951,
	versor: {x: 0.7071067811865475, y: 0.7071067811865475}
}
> makeVectorFeatures({x: 0, y: 0})
{
	length: 0,
	versor: {x: 0, y: 0}
}
Parameters:
Name Type Description
point object

A point representing a vector starting in the origin

Returns:
  • The vector features: {length, versor}
Type
object

(static) vectorLength2D(point) → {number}

Source:
Since:
  • 0.1.0

Calculates the length of a vector

Example
> vectorLength2D(1, 1)
1.4142135623730951
> vectorLength2D(0, 0)
0
Parameters:
Name Type Description
point object

A point representing a vector starting in the origin

Returns:
  • The vector length
Type
number