clojure.math.geometry.fit documentation

Geometric fitting.

fit-circle-2d

(fit-circle-2d pts)
Fits a circle to a sequence of points in plane by mapping points on
the Riemann sphere and fitting a plane in 3D. Returns a map with
keys :center (a vector), :radius (circle radius), and :radius2
(squared circle radius).

A. Strandlie, J. Wroldsen, R. Frühwirth, B. Lillekjendlie, Particle
tracks fitted on the Riemann sphere, Computer Physics
Communications, Volume 131, Issues 1–2, 1 September 2000, Pages
95-108, ISSN 0010-4655, http://dx.doi.org/10.1016/S0010-4655(00)00086-2.

fit-circle-3d

(fit-circle-3d pts)
Fits a plane to a sequence of points in 3D, and then fits a circle
to their projections to the plane. Returns a map with keys :center
(a 3D vector), :radius, :radius2, and :plane (a plane of the circle).

fit-line

(fit-line pts)
Fits a line to a sequence of points. Returns a map with keys :point and :direction.

fit-plane

(fit-plane pts)
Fits a plane to a sequence of points. Returns a map with
keys :point (a point belonging to the plane), :normal (a vector
normal to the plane), :basis (vectors of an orhonormal basis in the
plane, and :offset (the signed distance `d` from the plane to the
origin: given normal is unit vector [a b c], the plane equation is
`ax + by + cz + d = 0`).

The function can also be used to fit a line in 2D.