Liking cljdoc? Tell your friends :D

clunk.util


centerclj

(center window)
source

direction-vectorclj

(direction-vector r)

Calculate the unit direction vector based on the rotation angle.

Calculate the unit direction vector based on the rotation angle.
sourceraw docstring

invertclj

(invert v)

Multiply each component of the vector by -1.

Represents a rotation of 180 degrees.

Multiply each component of the vector by -1.

Represents a rotation of 180 degrees.
sourceraw docstring

magnitudeclj

(magnitude v)

Calculate the length of a vector.

Calculate the length of a vector.
sourceraw docstring

normalizeclj

(normalize v)

Calculate the unit vector of a given vector.

We calculate the reciprocal of the magnitude of the vector and multiply the components by this factor to avoid multiple division operations.

Calculate the unit vector of a given vector.

We calculate the reciprocal of the magnitude of the vector and
multiply the components by this factor to avoid multiple division
operations.
sourceraw docstring

orthogonalsclj

(orthogonals [x y])

Calculate the two orthogonal vectors to a given 2D vector.

Y axis is inverted so this returns [90-degrees-right-vector 90-degrees-left-vector]

Calculate the two orthogonal vectors to a given 2D vector.

Y axis is inverted so this returns [90-degrees-right-vector
                                    90-degrees-left-vector]
sourceraw docstring

poly-linesclj

(poly-lines poly)

Construct the lines that make up a polygon from its points.

Construct the lines that make up a polygon from its points.
sourceraw docstring

ratio-posclj

(ratio-pos window [x-factor y-factor])

Create an [x y] vector position at the specified ratio coordinates.

Create an `[x y]` vector position at the specified ratio
coordinates.
sourceraw docstring

rotate-vectorclj

(rotate-vector [x y :as v] r)

Rotate a vector about the origin by r degrees.

Checks first for r representing an integer number of rotations, in with case the vector will be unchanged.

Rotate a vector about the origin by `r` degrees.

Checks first for `r` representing an integer number of rotations, in
with case the vector will be unchanged.
sourceraw docstring

rotation-angleclj

(rotation-angle [x y])

Calculate the rotation angle of a vector.

Calculate the rotation angle of a vector.
sourceraw docstring

squared-magnitudeclj

(squared-magnitude [x y z])

Sum the squares of the components of a vector.

The if check on z is a lot faster than doing an apply or reduce across the vector.

Sum the squares of the components of a vector.

The `if` check on `z` is a lot faster than doing an `apply` or
`reduce` across the vector.
sourceraw docstring

unit-vectorclj

(unit-vector v)

Calculate the unit vector of a given vector.

Calculate the unit vector of a given vector.
sourceraw docstring

v<clj

(v< a b)

Determine if the magnitude of a vector a is less than the magnitude of vector b.

We can just compare the component squares to avoid the costly sqrt operations.

Determine if the magnitude of a vector `a` is less than the magnitude
of vector `b`.

We can just compare the component squares to avoid the costly `sqrt`
operations.
sourceraw docstring

v<=clj

(v<= a b)

Determine if the magnitude of a vector a is less than or equal to the magnitude of vector b.

We can just compare the component squares to avoid the costly sqrt operations.

Determine if the magnitude of a vector `a` is less than or equal to
the magnitude of vector `b`.

We can just compare the component squares to avoid the costly `sqrt`
operations.
sourceraw docstring

window-sizeclj

(window-size window)
source

zero-vector?clj

(zero-vector? v)

Predicate to check if a vector has length 0.

Predicate to check if a vector has length 0.
sourceraw docstring

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

× close