Utils.UnitVector: Convert input vector to unit length

Description Usage Arguments Value See Also Examples

View source: R/utils.R

Description

Convert input vector to unit length

Usage

1

Arguments

a

The vector

Value

A vector in the same direction as the input vector, but of unit length Will "work" on vectors of any number of dimensions, although it should be noted it's designed for 3D space use. For expediency, the function doesn't check the input vector is non-zero in length, and will return a vector of NaN values in that case.

See Also

Other utils: Utils.CrossProduct, Utils.DotProduct, Utils.VectorLength

Examples

1
2
  Utils.UnitVector(c(1,2,3))  [1] 0.2672612 0.5345225 0.8017837
  Utils.UnitVector(c(0,0,0)) [1] NaN NaN NaN

JerBoon/vecspace documentation built on May 26, 2019, 7:28 a.m.