vec3 -- 3D vectors for astrodynamics and rendering#
Minimal 3D vector library providing a shared type for astrodynamics, coordinate transforms, and rendering. Used as the common vector type across kepler, sgp4, globe, and coordinate packages.
Installation#
Install with opam:
$ opam install vec3
If opam cannot find the package, it may not yet be released in the public
opam-repository. Add the overlay repository, then install it:
$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install vec3
Usage#
open Vec3
let a = v 1.0 2.0 3.0
let b = v 4.0 5.0 6.0
let c = add a b
let d = cross a b
let len = length c
let unit = normalize c
let () = Fmt.pr "%a cross %a (length: %f)@." pp unit pp d len
API#
v x y z-- create a vectorzero-- the zero vectoradd,sub,scale,negate-- arithmeticdot,cross-- productslength,distance-- metricsnormalize-- unit vector (returnszeroif near-zero input)equal ?eps-- approximate equality (default epsilon: 1e-12)pp-- pretty-printer
License#
ISC