VectorN

is an n-dimensional vector data type. Its implementation is array-backed.

=

defn

(Fn [(Ref (VectorN a) b), (Ref (VectorN a) b)] Bool)

                        (= o1 o2)
                    

add

defn

(Fn [(Ref (VectorN a) b), (Ref (VectorN a) c)] (Maybe (VectorN a)))

                        (add a b)
                    

angle-between

defn

(Fn [(Ref (VectorN a) b), (Ref (VectorN a) b)] (Maybe a))

                        (angle-between a b)
                    

Get the angle between two vectors a and b.

anti-parallel?

defn

(Fn [(Ref (VectorN a) b), (Ref (VectorN a) b)] (Maybe Bool))

                        (anti-parallel? a b)
                    

Check whether the two vectors a and b are anti-parallel.

copy

template

(Fn [(Ref (VectorN a) b)] (VectorN a))

copies a VectorN.

delete

template

(Fn [(VectorN a)] ())

deletes a VectorN. Should usually not be called manually.

dist

defn

(Fn [(Ref (VectorN a) b), (Ref (VectorN a) c)] (Maybe a))

                        (dist a b)
                    

Get the distance between the vectors a and b.

div

defn

(Fn [(Ref (VectorN a) b), a] (VectorN a))

                        (div a n)
                    

dot

defn

(Fn [(Ref (VectorN a) b), (Ref (VectorN a) c)] (Maybe a))

                        (dot x y)
                    

Get the dot product of the two vectors x and y.

init

template

(Fn [Int, (Array a)] (VectorN a))

creates a VectorN.

mag

defn

(Fn [(Ref (VectorN a) b)] a)

                        (mag o)
                    

Get the magnitude of a vector.

mag-sq

defn

(Fn [(Ref (VectorN a) b)] a)

                        (mag-sq o)
                    

Get the squared magnitude of a vector.

mul

defn

(Fn [(Ref (VectorN a) b), a] (VectorN a))

                        (mul a n)
                    

n

instantiate

(Fn [(Ref (VectorN a) b)] (Ref Int b))

gets the n property of a VectorN.

normalize

defn

(Fn [(Ref (VectorN a) b)] (VectorN a))

                        (normalize o)
                    

Normalize a vector.

parallel?

defn

(Fn [(Ref (VectorN a) b), (Ref (VectorN a) b)] (Maybe Bool))

                        (parallel? a b)
                    

Check whether the two vectors a and b are parallel.

perpendicular?

defn

(Fn [(Ref (VectorN a) b), (Ref (VectorN a) b)] (Maybe Bool))

                        (perpendicular? a b)
                    

Check whether the two vectors a and b are perpendicular.

prn

template

(Fn [(Ref (VectorN a) b)] String)

converts a VectorN to a string.

random-sized

defn

(Fn [Int] (VectorN a))

                        (random-sized n)
                    

set-n

instantiate

(Fn [(VectorN a), Int] (VectorN a))

sets the n property of a VectorN.

set-n!

instantiate

(Fn [(Ref (VectorN a) b), Int] ())

sets the n property of a VectorN in place.

set-v

template

(Fn [(VectorN a), (Array a)] (VectorN a))

sets the v property of a VectorN.

set-v!

template

(Fn [(Ref (VectorN a) b), (Array a)] ())

sets the v property of a VectorN in place.

str

template

(Fn [(Ref (VectorN a) b)] String)

converts a VectorN to a string.

sub

defn

(Fn [(Ref (VectorN a) b), (Ref (VectorN a) c)] (Maybe (VectorN a)))

                        (sub a b)
                    

update-n

instantiate

(Fn [(VectorN a), (Ref (Fn [Int] Int b) c)] (VectorN a))

updates the n property of a (VectorN f) using a function f.

update-v

instantiate

(Fn [(VectorN a), (Ref (Fn [(Array a)] (Array a) b) c)] (VectorN a))

updates the v property of a (VectorN f) using a function f.

v

instantiate

(Fn [(Ref (VectorN a) b)] (Ref (Array a) b))

gets the v property of a VectorN.

vlerp

defn

(Fn [(Ref (VectorN a) b), (Ref (VectorN a) c), a] (Maybe (VectorN a)))

                        (vlerp a b amnt)
                    

Linearly interpolate between the two vectors a and b by amnt (between 0 and 1).

zero-sized

defn

(Fn [Int] (VectorN a))

                        (zero-sized n)
                    

zip

defn

(Fn [(Fn [a, b] c d), (Ref (VectorN a) e), (Ref (VectorN b) f)] (Maybe (VectorN c)))

                        (zip f a b)
                    

zip-

defn

(Fn [(Fn [a, b] c d), (Ref (Array a) e), (Ref (Array b) f)] (VectorN c))

                        (zip- f a b)