Liking cljdoc? Tell your friends :D

some.vec

A collection of helper functions that work on vectors, both in the sense of a collection and in the directional sense.

A collection of helper functions that work on vectors,
both in the sense of a collection and in the directional sense.
raw docstring

*clj/s

(* a b)

Component-wise multiplication of two n-dimensional vectors. If the second argument is a scalar, all components of the first argument gets multiplied by it.

** Example **

(some.vec/* [2 2][2 2])
;; (4 4)

(some.vec/* [2 2] 4)
;; (8 8)
Component-wise multiplication of two n-dimensional vectors.
If the second argument is a scalar, all components of the first
argument gets multiplied by it.

** Example **
```clojure
(some.vec/* [2 2][2 2])
;; (4 4)

(some.vec/* [2 2] 4)
;; (8 8)
```
sourceraw docstring

+clj/s

(+ a b)

Adds two vectors of the same dimension together. If the second argument is a scalar, it gets added to all components of the first argument.

** Example **

(some.vec/+ [1 1][1 1])
;; (2 2)

(some.vec/+ [1 1] 2)
;; (3 3)
Adds two vectors of the same dimension together.
If the second argument is a scalar, it gets added to
all components of the first argument.

** Example **

```clojure
(some.vec/+ [1 1][1 1])
;; (2 2)

(some.vec/+ [1 1] 2)
;; (3 3)
```
sourceraw docstring

-clj/s

(- a b)

Substracts 2 vectors of same dimension. If the second argument is a scalar, all components of the first argument gets subtracted by it.

** Example **

(some.vec/- [2 2][1 1])
;; (1 1)

(some.vec/- [5 5] 1)
;; (4 4)
Substracts 2 vectors of same dimension. If the second argument is a
scalar, all components of the first argument gets subtracted by it.

** Example **
```clojure
(some.vec/- [2 2][1 1])
;; (1 1)

(some.vec/- [5 5] 1)
;; (4 4)
```
sourceraw docstring

/clj/s

(/ a b)

Divides vector a by vector b. Both vectors should be of the same dimension. If the second argument is a scalar, all components of the first argument gets divided by it.

** Example **

(some.vec// [2 2][2 2])
;; (1 1)

(some.vec// [2 2] 2)
;; (1 1)
Divides vector a by vector b. Both vectors should be of the same
dimension. If the second argument is a scalar, all components
of the first argument gets divided by it.

** Example **

```clojure
(some.vec// [2 2][2 2])
;; (1 1)

(some.vec// [2 2] 2)
;; (1 1)
```
sourceraw docstring

angleclj/s

(angle v)

Returns the angle of a 2D vector in radians.

Returns the angle of a 2D vector in radians.
sourceraw docstring

angle-betweenclj/s

(angle-between v1 v2)

Returns the angle between two 2D vectors, calculated using the difference between their angles.

Returns the angle between two 2D vectors, calculated using the
difference between their angles.
sourceraw docstring

averageclj/s

(average v)

Returns the average of a vector.

Returns the average of a vector.
sourceraw docstring

distanceclj/s

(distance v1 v2)

Calculates the distance between two vectors of same dimension.

Calculates the distance between two vectors of same dimension.
sourceraw docstring

dotclj/s

(dot v1 v2)

Returns the dot product of two n-dimensional vectors.

Returns the dot product of two n-dimensional vectors.
sourceraw docstring

dx->xclj/s

(dx->x v)
(dx->x v start)

Treats each component of a vector as an interval and creates a running sum of the intervals.

For example: [1 1 1] -> [0 1 2 3] [1 2 3] -> [0 1 3 6]

Treats each component of a vector as an interval and
creates a running sum of the intervals.

For example:
[1 1 1] -> [0 1 2 3]
[1 2 3] -> [0 1 3 6]
sourceraw docstring

from-angleclj/s

(from-angle theta)

Returns a 2D unit vector with given angle

Returns a 2D unit vector with given angle
sourceraw docstring

from-polarclj/s

(from-polar theta radius)

Returns a 2D vector from polar coordinates

Returns a 2D vector from polar coordinates
sourceraw docstring

indexedclj/s

(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
sourceraw docstring

lengthclj/s

(length v)

Returns the length of a vector of any dimension.

Returns the length of a vector of any dimension.
sourceraw docstring

lerpclj/s

(lerp v1 v2 t)

Lerps between two vectors

Lerps between two vectors
sourceraw docstring

lerpnclj/s

(lerpn a b t)
source

limitclj/s

(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.
sourceraw docstring

mat-transclj/s

(mat-trans mat)

Rotates an ND matrix (vec of vecs)

Rotates an ND matrix (vec of vecs)
sourceraw docstring

normalizeclj/s

(normalize v)

Returns a vector of any dimension normalized

Returns a vector of any dimension normalized
sourceraw docstring

normalize-rangeclj/s

(normalize-range v)

Divides every element in vector by total sum

Divides every element in vector by total sum
sourceraw docstring

padclj/s

(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
sourceraw docstring

pad-endclj/s

(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
sourceraw docstring

pad-startclj/s

(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
sourceraw docstring

pad-wrapclj/s

(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
sourceraw docstring

randomclj/s

(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.
sourceraw docstring

random-polarclj/s

(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.
sourceraw docstring

random-replaceclj/s

(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
sourceraw docstring

random10clj/s

(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.
sourceraw docstring

range-fillclj/s

(range-fill vec start stop value)

Fill a range of elements in vector with value.

** Example **

(some.vec/range-fill [0 1 2 3 4 5] 2 4 69)
;; [0 1 69 69 69 5]
Fill a range of elements in vector with value.

** Example **

```clojure
(some.vec/range-fill [0 1 2 3 4 5] 2 4 69)
;; [0 1 69 69 69 5]
```
sourceraw docstring

range-replaceclj/s

(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
sourceraw docstring

restvclj/s

(restv col)

returns the rest of a collection as a vector

returns the rest of a collection as a vector
sourceraw docstring

rotateclj/s

(rotate v theta)

rotates a 2D vector by an angle

rotates a 2D vector by an angle
sourceraw docstring

selectclj/s

(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.
sourceraw docstring

set-lengthclj/s

(set-length v l)

Returns the vector v with given length l.

Returns the vector v with given length l.
sourceraw docstring

splitclj/s

(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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close