Liking cljdoc? Tell your friends :D

clunk.util


centerclj

(center window)

The [x y] position vector at the center of the screen.

The `[x y]` position vector at the center of the screen.
sourceraw docstring

centreclj

source

convex?clj

(convex? poly)

Are all the corners of the polygon turning in the same direction?

Are all the corners of the polygon turning in the same direction?
sourceraw docstring

crossclj

(cross [ax ay az] [bx by bz])

Calculate the cross product of two vectors.

Calculate the cross product of two vectors.
sourceraw docstring

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

ellipse-pointsclj

(ellipse-points [w h] & {:keys [num-points] :or {num-points 32}})

Generate a collection of [x y] points in CCW order around an ellipse with dimensions [w h].

The points are all in the [+x +y] quadrant so the clunk.sprite/pos-offsets function works by default.

Generate a collection of `[x y]` points in CCW order around an
ellipse with dimensions `[w h]`.

The points are all in the `[+x +y]` quadrant so the
`clunk.sprite/pos-offsets` function works by default.
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

left-turn?clj

(left-turn? [ax ay] [bx by] [cx cy])

Is the corner from A->B->C a left turn?

Is the corner from A->B->C a left turn?
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

pos-in-tri?clj

(pos-in-tri? pos [a b c])

Is the position pos inside the triangle ABC?

Is the position `pos` inside the triangle ABC?
sourceraw docstring

remove-nthclj

(remove-nth n xs)

Remove the nth element from a collection.

Remove the nth element from a collection.
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

split-byclj

(split-by pred coll)

Split a collection using a predicate.

Returns [things-that-were-true things-that-were-false].

Split a collection using a predicate.

Returns `[things-that-were-true things-that-were-false]`.
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

triangulateclj

(triangulate poly)

Split a concave polygon with no holes or overlapping edges into a collection of triangles which can be drawn.

Split a concave polygon with no holes or overlapping edges into a
collection of triangles which can be drawn.
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-posclj

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

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

Create an `[x y]` position vector at the specified ratio
coordinates.
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