unitvector: Normalize vectors to unit length

View source: R/unitvector.R

unitvectorR Documentation

Normalize vectors to unit length

Description

Computes unit vectors from one or more vectors.

Usage

unitvector(x)

Arguments

x

Numeric vector or matrix. If a matrix is supplied, each row is interpreted as a vector.

Value

An object of the same type and dimensions as x, with each vector normalized to unit length. Zero vectors are returned unchanged.

See Also

vectornorm


cooltools documentation built on Sept. 11, 2026, 5:06 p.m.