Generation of unit vector(s) with a given angle | R Documentation |
Generation of unit vector(s) with a given angle from a given unit vector.
vec(x, n = 1, deg = 90)
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. |
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).
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. |
Michail Tsagris.
R implementation and documentation: Michail Tsagris mtsagris@uoc.gr and Giorgos Athineou <gioathineou@gmail.com>.
rvmf, rbingham, rfb
x <- rnorm(10)
x <- x / sqrt( sum(x^2) )
a <- vec(x, 20, 90)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.