(center window)
The [x y]
position vector at the center of the screen.
The `[x y]` position vector at the center of the screen.
(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?
(cross [ax ay az] [bx by bz])
Calculate the cross product of two vectors.
Calculate the cross product of two vectors.
(direction-vector r)
Calculate the unit direction vector based on the rotation angle.
Calculate the unit direction vector based on the rotation angle.
(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.
(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.
(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?
(magnitude v)
Calculate the length of a vector.
Calculate the length of a vector.
(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.
(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]
(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.
(pos-in-tri? pos [a b c])
Is the position pos
inside the triangle ABC?
Is the position `pos` inside the triangle ABC?
(remove-nth n xs)
Remove the nth element from a collection.
Remove the nth element from a collection.
(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.
(rotation-angle [x y])
Calculate the rotation angle of a vector.
Calculate the rotation angle of a vector.
(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]`.
(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.
(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.
(unit-vector v)
Calculate the unit vector of a given vector.
Calculate the unit vector of a given vector.
(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.
(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.
(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.
(zero-vector? v)
Predicate to check if a vector has length 0.
Predicate to check if a vector has length 0.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close