Kozai::Vector3
A three-component vector of Float64, used for every position, velocity and
direction in the library.
This is a struct on purpose. Pass prediction over a week for a hundred
satellites runs to millions of propagator steps, and each step produces
several intermediate vectors. As a class, every one of those would be a heap
allocation and the garbage collector would dominate the run; as a value type
they live on the stack and cost nothing. spec/allocation_spec.cr asserts
that the hot loop allocates zero bytes, which is only achievable this way.
Every operation returns a new value; nothing here mutates in place.
Units are whatever the caller is working in — the propagator produces
kilometres and km/s, Frames and Observer keep that convention.
Constructors
Instance methods
Angle to other, in radians, in the range 0..PI.
Returns 0.0 if either vector has zero length.
Whether every component is finite.
A propagator that has diverged reports itself through SGP4::ErrorCode,
but pathological elements can still produce infinities in downstream
geometry; this is the cheap guard for that.
Squared Euclidean length.
Prefer this to #magnitude when only comparing lengths: it skips the
square root.
A unit vector pointing the same way.
Returns Vector3.zero for a zero-length vector rather than producing
NaNs, so that callers walking a track do not have to special-case a
degenerate step.