vec: Generation of unit vector(s) with a given angle

View source: R/vec.R

Generation of unit vector(s) with a given angleR Documentation

Generation of unit vector(s) with a given angle

Description

Generation of unit vector(s) with a given angle from a given unit vector.

Usage

vec(x, n = 1, deg = 90)

Arguments

x

A unit vector. If it is not a unit vector it becomes one.

n

The number of unit vectors to return.

deg

The angle between the given vector and the n vectors to be returned. This must be in degrees and it has to be between 0 and 180 degrees. If the angle is 0, the same unit vector will be returned. If the angle is 180, the same unit vector with the signs changed will be returned.

Details

The user provides a unit vector and the degrees. The function will return n unit vectors whose angle with the given unit vector equals the degrees given. For example, if you want 10 unit vectors purpendicualr to the x put vec(x, 10, 90).

Value

A list including:

runtime

The runtime of the procedure.

crit

The calculated angle between the given unit vector and each of the generated unit vectors.

mat

A matrix with the n unit vectors.

Author(s)

Michail Tsagris.

R implementation and documentation: Michail Tsagris mtsagris@uoc.gr and Giorgos Athineou <gioathineou@gmail.com>.

See Also

rvmf, rbingham, rfb

Examples

x <- rnorm(10)
x <- x / sqrt( sum(x^2) )
a <- vec(x, 20, 90)

Directional documentation built on Oct. 12, 2023, 1:07 a.m.