Something went wrong. Try again.
3D vectors for astrodynamics and rendering
Something went wrong. Try again.
Files
README.md
vec3 #
An orbit propagator produces positions and velocities, a coordinate transform
rotates them, and a globe renderer draws them. If each library defines its own
vector type, every boundary between them needs a conversion. vec3 is the
small 3D vector type they share: the kepler, sgp4, globe and
coordinate packages all exchange Vec3.t values. It is a record of three
floats, and the unit of the components (kilometres, metres per second, GL
units) depends on the caller.
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 zbuilds a vector andzerois the zero vector.add,sub,scaleandnegateare the arithmetic.dotandcrossare the scalar and vector products.lengthis the Euclidean norm anddistancethe norm of the difference.normalizeis the unit vector in the same direction, orzerowhen the
length is below 1e-12.equal ?epscompares component by component withineps(defaults to
1e-12).ppformats a vector to four decimal places.
Licence #
ISC