2D geometric point and vector helpers. All in terms of clojure vectors [x y]. Uses float precision for consistency with JBox2d.
2D geometric point and vector helpers. All in terms of clojure vectors [x y]. Uses float precision for consistency with JBox2d.
(abs x)
Absolute value; avoids reflection from overloaded Math/abs
Absolute value; avoids reflection from overloaded Math/abs
(angle-intersection xy0 ang0 xy1 ang1)
Point of intersection of two lines in the plane.
Point of intersection of two lines in the plane.
(horizontal-angle? ang)
(horizontal-angle? ang tol)
Is angle horizontal, within +/- 1.5 degrees by default.
Is angle horizontal, within +/- 1.5 degrees by default.
(in-pi-pi angle)
Returns the angle expressed in the range -pi to pi.
Returns the angle expressed in the range -pi to pi.
(interior-angle [v0 v1 v2])
Interior angle of a triple of points using law of cosines: cosC = (a^2 + b^2 - c^2) / (2ab) where, in a triangle, angle C is opposite side c.
Interior angle of a triple of points using law of cosines: cosC = (a^2 + b^2 - c^2) / (2ab) where, in a triangle, angle C is opposite side c.
(line-intersection [x0 y0] m0 [x1 y1] m1)
Point of intersection of two lines in the plane. First line passes through [x0 y0] with gradient m0. Other line passes through [x1 y1] with gradient m1. Gradient can be passed as nil for vertical lines.
Point of intersection of two lines in the plane. First line passes through [x0 y0] with gradient m0. Other line passes through [x1 y1] with gradient m1. Gradient can be passed as nil for vertical lines.
(polar-xy mag angle)
Convert polar coordinates (magnitude, angle) to cartesian coordinates (x, y).
Convert polar coordinates (magnitude, angle) to cartesian coordinates (x, y).
(poly-edge-point vv angle origin-pt)
Finds point on edge of a convex polygon shape (given by
counter-clockwise vertices) at a given angle
from origin-pt
.
Finds point on edge of a convex polygon shape (given by counter-clockwise vertices) at a given `angle` from `origin-pt`.
(poly-flip-x vv)
(poly-flip-x vv x0)
Flip polygon coordinates horizontally, by default around x=0.
Flip polygon coordinates horizontally, by default around x=0.
(poly-flip-y vv)
(poly-flip-y vv y0)
Flip polygon coordinates vertically, by default around y=0.
Flip polygon coordinates vertically, by default around y=0.
(v-add v1 v2)
Add a 2d geometric vector to another.
Add a 2d geometric vector to another.
(v-angle [x y])
Angle of a 2d geometric vector in radians in range -pi to pi.
Angle of a 2d geometric vector in radians in range -pi to pi.
(v-dist v1 v2)
Distance from one 2d point to another.
Distance from one 2d point to another.
(v-interp v1 v2 frac)
Find a point frac
fraction of the way from v1 to v2 by linear
interpolation.
Find a point `frac` fraction of the way from v1 to v2 by linear interpolation.
(v-mag [x y])
Magnitude of a 2d geometric vector
Magnitude of a 2d geometric vector
(v-scale v)
(v-scale [x y] s)
Multiply elements of a 2d vector by a scalar; Default is to normalise to unit length.
Multiply elements of a 2d vector by a scalar; Default is to normalise to unit length.
(v-sub v1 v2)
Subtract a 2d geometric vector from another (v1 - v2).
Subtract a 2d geometric vector from another (v1 - v2).
(vertical-angle? ang)
(vertical-angle? ang tol)
Is angle vertical, within +/- 1.5 degrees by default.
Is angle vertical, within +/- 1.5 degrees by default.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close