Vector2

is a two-dimensional vector data type.

=

defn

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

                        (= o1 o2)
                    

add

defn

(Fn [(Ref (Vector2 a) b), (Ref (Vector2 a) c)] (Vector2 a))

                        (add a b)
                    

angle-between

defn

(Fn [(Ref (Vector2 a) b), (Ref (Vector2 a) c)] a)

                        (angle-between a b)
                    

Get the angle between two vectors a and b.

anti-parallel?

defn

(Fn [(Ref (Vector2 a) b), (Ref (Vector2 a) c)] Bool)

                        (anti-parallel? a b)
                    

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

copy

template

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

copies a Vector2.

delete

template

(Fn [(Vector2 a)] ())

deletes a Vector2. Should usually not be called manually.

dist

defn

(Fn [(Ref (Vector2 a) b), (Ref (Vector2 a) c)] a)

                        (dist a b)
                    

Get the distance between the vectors a and b.

div

defn

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

                        (div a n)
                    

dot

defn

(Fn [(Ref (Vector2 a) b), (Ref (Vector2 a) c)] a)

                        (dot a b)
                    

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

heading

defn

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

                        (heading a)
                    

Get the heading of the vector a.

init

template

(Fn [a, a] (Vector2 a))

creates a Vector2.

mag

defn

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

                        (mag o)
                    

Get the magnitude of a vector.

mag-sq

defn

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

                        (mag-sq o)
                    

Get the squared magnitude of a vector.

map

defn

(Fn [(Fn [a] b c), (Ref (Vector2 a) d)] (Vector2 b))

                        (map f v)
                    

mul

defn

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

                        (mul a n)
                    

normalize

defn

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

                        (normalize o)
                    

Normalize a vector.

parallel?

defn

(Fn [(Ref (Vector2 a) b), (Ref (Vector2 a) c)] Bool)

                        (parallel? a b)
                    

Check whether the two vectors a and b are parallel.

perpendicular?

defn

(Fn [(Ref (Vector2 a) b), (Ref (Vector2 a) c)] Bool)

                        (perpendicular? a b)
                    

Check whether the two vectors a and b are perpendicular.

prn

template

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

converts a Vector2 to a string.

random

defn

(Fn [] (Vector2 a))

                        (random)
                    

rotate

defn

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

                        (rotate a n)
                    

Rotate the vector a by the radians n.

set-x

template

(Fn [(Vector2 a), a] (Vector2 a))

sets the x property of a Vector2.

set-x!

template

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

sets the x property of a Vector2 in place.

set-y

template

(Fn [(Vector2 a), a] (Vector2 a))

sets the y property of a Vector2.

set-y!

template

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

sets the y property of a Vector2 in place.

str

template

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

converts a Vector2 to a string.

sub

defn

(Fn [(Ref (Vector2 a) b), (Ref (Vector2 a) c)] (Vector2 a))

                        (sub a b)
                    

sum

defn

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

                        (sum o)
                    

update-x

instantiate

(Fn [(Vector2 a), (Ref (Fn [a] a b) c)] (Vector2 a))

updates the x property of a (Vector2 f) using a function f.

update-y

instantiate

(Fn [(Vector2 a), (Ref (Fn [a] a b) c)] (Vector2 a))

updates the y property of a (Vector2 f) using a function f.

vapprox

defn

(Fn [(Ref (Vector2 a) b), (Ref (Vector2 a) c)] Bool)

                        (vapprox a b)
                    

Check whether the vectors a and b are approximately equal.

vlerp

defn

(Fn [(Ref (Vector2 a) b), (Ref (Vector2 a) c), a] (Vector2 a))

                        (vlerp a b amnt)
                    

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

vreduce

defn

(Fn [(Fn [a, b] a c), a, (Ref (Vector2 b) d)] a)

                        (vreduce f i v)
                    

x

instantiate

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

gets the x property of a Vector2.

y

instantiate

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

gets the y property of a Vector2.

zero

defn

(Fn [] (Vector2 a))

                        (zero)
                    

zip

defn

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

                        (zip f a b)