A collection of vector functions. Vectors are treated both like collections and directions.
A collection of vector functions. Vectors are treated both like collections and directions.
(add v1 v2)
adds two vectors of same dimension together
adds two vectors of same dimension together
(add-scalar v scalar)
Adds a scalar to a vector
Adds a scalar to a vector
(angle-between v1 v2)
Calculates the angle between two 2D Vectors using angle difference.
Calculates the angle between two 2D Vectors using angle difference.
(average v)
calculates the average of the vector
calculates the average of the vector
(distance v1 v2)
Calculates distance between two vectors of same dimension
Calculates distance between two vectors of same dimension
(div v1 v2)
Divides one vector by another. Both must be same dimension.
Divides one vector by another. Both must be same dimension.
(div-scalar v scalar)
Divides vector by a scalar
Divides vector by a scalar
(from-angle theta)
Returns a 2D unit vector with given angle
Returns a 2D unit vector with given angle
(from-polar theta radius)
Returns a 2D vector from polar coordinates
Returns a 2D vector from polar coordinates
(indexed coll)
pairs each element in a collection as an indexed tuple and return as vector
pairs each element in a collection as an indexed tuple and return as vector
(length v)
Returns the length of a vector of any dimension.
Returns the length of a vector of any dimension.
(limit v l)
If vector v is bigger than limit l, vector gets scaled to l.
If vector v is bigger than limit l, vector gets scaled to l.
(mat-trans mat)
Rotates an ND matrix (vec of vecs)
Rotates an ND matrix (vec of vecs)
(mul v1 v2)
Multiplied two vectors of same dimensions
Multiplied two vectors of same dimensions
(mul-scalar v scalar)
Multiplies vector by a scalar
Multiplies vector by a scalar
(normalize v)
Returns a vector of any dimension normalized
Returns a vector of any dimension normalized
(normalize-range list)
Divides every element in vector by total sum
Divides every element in vector by total sum
(pad vector value)
(pad vector value pad-size)
pads start and end of vector with value and pad size
pads start and end of vector with value and pad size
(pad-end vector value)
(pad-end vector value pad-size)
pads end of vector with value and pad size
pads end of vector with value and pad size
(pad-start vector value)
(pad-start vector value pad-size)
pads start of vector with value and pad size
pads start of vector with value and pad size
(pad-wrap vector)
pads start of vector with end and end of vector with start
pads start of vector with end and end of vector with start
(random N)
(random N f)
Returns a random vector of N dimension. Values between 0 and 1. An optional second argument can be given as another RNG function.
Returns a random vector of N dimension. Values between 0 and 1. An optional second argument can be given as another RNG function.
(random-polar)
(random-polar f)
Returns a 2D vector from a random angle and radius between 0 and 1. An optional second argument can be given as another RNG function.
Returns a 2D vector from a random angle and radius between 0 and 1. An optional second argument can be given as another RNG function.
(random-replace vec value)
(random-replace vec value f)
Replace random element in vector with a value
Replace random element in vector with a value
(random10 N)
(random10 N f)
Returns a vector of size N of random 1s and 0s. An optional second argument can be given as another RNG function.
Returns a vector of size N of random 1s and 0s. An optional second argument can be given as another RNG function.
(range-fill vec start stop value)
fill range of elements in vector with value
fill range of elements in vector with value
(range-replace vec value position)
replace elements of vector with another set at given position
replace elements of vector with another set at given position
(restv col)
returns the rest of a collection as a vector
returns the rest of a collection as a vector
(rotate v theta)
rotates a 2D vector by an angle
rotates a 2D vector by an angle
(select v a b)
Returns the selection of a vector from index a to and including index b.
Returns the selection of a vector from index a to and including index b.
(set-length v l)
Returns the vector v with given length l.
Returns the vector v with given length l.
(split v i)
Return two collections split from a vector with i as the index starting the second group.
Return two collections split from a vector with i as the index starting the second group.
(sub v1 v2)
Substracts 2 vectors of same dimension
Substracts 2 vectors of same dimension
(sub-scalar v scalar)
Subtracts scalar from vector
Subtracts scalar from vector
(sum v)
Returns the sum of all elements in a vector
Returns the sum of all elements in a vector
(vec2 value)
Creates a 2d vector of given value
Creates a 2d vector of given value
(vec3 value)
Creates a 3d vector of given value
Creates a 3d vector of given value
(vec4 value)
Creates a 4d vector of given value
Creates a 4d vector of given value
(vecn value n)
Creates an n-dimensional vector of given value
Creates an n-dimensional vector of given value
(zeros n)
Creates an n-dimensional vector of zeroes
Creates an n-dimensional vector of zeroes
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close