lob 0.11.0
Exterior ballistics library — API + technical reference
Loading...
Searching...
No Matches
lob.hpp
Go to the documentation of this file.
1// Copyright (c) 2025 Joel Benway
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Please see end of file for extended copyright information
4
5#pragma once
6
7#include <array>
8#include <cstddef>
9#include <cstdint>
10
11#include "lob/lob.h"
12
13namespace lob {
14
18constexpr size_t kLobCoeffsSize = LOB_SPLINE_SEGMENTS * static_cast<size_t>(4);
19
29
38
58
60enum class ErrorT : LobErrorT {
95};
96
108struct Context {
109 double drag_coeff;
111 double mass;
116 double zero_angle;
120 double k_lapse;
121 double max_time;
122 std::array<float, kLobCoeffsSize> drags;
123 uint16_t velocity;
124 uint16_t minimum_speed;
125 uint16_t step_size;
127};
128
129static_assert(sizeof(Context) == sizeof(::LobContext),
130 "Context vs LobContext size mismatch");
131static_assert(alignof(Context) == alignof(::LobContext),
132 "Context vs LobContext alignment mismatch");
133static_assert(offsetof(Context, drag_coeff) ==
134 offsetof(::LobContext, drag_coeff),
135 "drag_coeff offset drift");
136static_assert(offsetof(Context, speed_of_sound) ==
137 offsetof(::LobContext, speed_of_sound),
138 "speed_of_sound offset drift");
139static_assert(offsetof(Context, mass) == offsetof(::LobContext, mass),
140 "mass offset drift");
141static_assert(offsetof(Context, optic_height) ==
142 offsetof(::LobContext, optic_height),
143 "optic_height offset drift");
144static_assert(offsetof(Context, gravity) == offsetof(::LobContext, gravity),
145 "gravity offset drift");
146static_assert(offsetof(Context, wind) == offsetof(::LobContext, wind),
147 "wind offset drift");
148static_assert(offsetof(Context, coriolis) == offsetof(::LobContext, coriolis),
149 "coriolis offset drift");
150static_assert(offsetof(Context, zero_angle) ==
151 offsetof(::LobContext, zero_angle),
152 "zero_angle offset drift");
153static_assert(offsetof(Context, stability_factor) ==
154 offsetof(::LobContext, stability_factor),
155 "stability_factor offset drift");
156static_assert(offsetof(Context, aerodynamic_jump) ==
157 offsetof(::LobContext, aerodynamic_jump),
158 "aerodynamic_jump offset drift");
159static_assert(offsetof(Context, spindrift_factor) ==
160 offsetof(::LobContext, spindrift_factor),
161 "spindrift_factor offset drift");
162static_assert(offsetof(Context, max_time) == offsetof(::LobContext, max_time),
163 "max_time offset drift");
164static_assert(offsetof(Context, drags) == offsetof(::LobContext, drags),
165 "drags offset drift");
166static_assert(offsetof(Context, velocity) == offsetof(::LobContext, velocity),
167 "velocity offset drift");
168static_assert(offsetof(Context, minimum_speed) ==
169 offsetof(::LobContext, minimum_speed),
170 "minimum_speed offset drift");
171static_assert(offsetof(Context, step_size) == offsetof(::LobContext, step_size),
172 "step_size offset drift");
173static_assert(offsetof(Context, error) == offsetof(::LobContext, error),
174 "error offset drift");
175static_assert(static_cast<::LobErrorT>(ErrorT::kNone) == ::kLobErrorNone,
176 "ErrorT kNone value drift");
177static_assert(static_cast<::LobErrorT>(ErrorT::kNotFormed) ==
179 "ErrorT kNotFormed value drift");
180
184
185inline bool operator==(::LobErrorT a, ErrorT b) noexcept {
186 return a == static_cast<::LobErrorT>(b);
187}
188inline bool operator!=(::LobErrorT a, ErrorT b) noexcept {
189 return a != static_cast<::LobErrorT>(b);
190}
191inline bool operator==(ErrorT a, ::LobErrorT b) noexcept {
192 return static_cast<::LobErrorT>(a) == b;
193}
194inline bool operator!=(ErrorT a, ::LobErrorT b) noexcept {
195 return static_cast<::LobErrorT>(a) != b;
196}
197
202class Builder {
203 public:
204 Builder() : builder_{} {
205 ::LobBuilderInit(&builder_);
206 }
207 ~Builder() { ::LobBuilderDestroy(&builder_); }
208
209 Builder(const Builder& other) : builder_{} {
210 ::LobBuilderCopy(&builder_, &other.builder_);
211 }
212
213 Builder(Builder&& other) noexcept : builder_{} {
214 ::LobBuilderCopy(&builder_, &other.builder_);
215 ::LobBuilderReset(&other.builder_);
216 }
217
219 Builder& operator=(const Builder& rhs) {
220 if (this != &rhs) {
221 ::LobBuilderCopy(&builder_, &rhs.builder_);
222 }
223 return *this;
224 }
225
227 Builder& operator=(Builder&& rhs) noexcept {
228 if (this != &rhs) {
229 ::LobBuilderCopy(&builder_, &rhs.builder_);
230 ::LobBuilderReset(&rhs.builder_);
231 }
232 return *this;
233 }
234
241 ::LobBuilderBallisticCoefficientPsi(&builder_, value);
242 return *this;
243 }
244
251 ::LobBuilderBCAtmosphere(&builder_,
252 static_cast<::LobAtmosphereReferenceT>(type));
253 return *this;
254 }
255
262 ::LobBuilderBCAtmosphere(&builder_, type);
263 return *this;
264 }
265
277 static_cast<::LobDragFunctionT>(type));
278 return *this;
279 }
280
291 ::LobBuilderBCDragFunction(&builder_, type);
292 return *this;
293 }
294
300 Builder& DiameterInch(double value) {
301 ::LobBuilderDiameterInch(&builder_, value);
302 return *this;
303 }
304
311 ::LobBuilderMeplatDiameterInch(&builder_, value);
312 return *this;
313 }
314
320 Builder& BaseDiameterInch(double value) {
321 ::LobBuilderBaseDiameterInch(&builder_, value);
322 return *this;
323 }
324
330 Builder& LengthInch(double value) {
331 ::LobBuilderLengthInch(&builder_, value);
332 return *this;
333 }
334
340 Builder& NoseLengthInch(double value) {
341 ::LobBuilderNoseLengthInch(&builder_, value);
342 return *this;
343 }
344
350 Builder& TailLengthInch(double value) {
351 ::LobBuilderTailLengthInch(&builder_, value);
352 return *this;
353 }
354
360 Builder& OgiveRtR(double value) {
361 ::LobBuilderOgiveRtR(&builder_, value);
362 return *this;
363 }
364
381 Builder& MachVsDragTable(const float* pmachs, const float* pdrags,
382 size_t size) {
383 ::LobBuilderSplineFitTable(&builder_, pmachs, pdrags, size);
384 return *this;
385 }
386
403 template <size_t N>
404 Builder& MachVsDragTable(const std::array<float, N>& machs,
405 const std::array<float, N>& drags) {
406 ::LobBuilderSplineFitTable(&builder_, machs.data(), drags.data(), N);
407 return *this;
408 }
409 template <size_t N>
410 Builder& MachVsDragTable(const std::array<float, N>&& machs,
411 const std::array<float, N>& drags) = delete;
412 template <size_t N>
413 Builder& MachVsDragTable(const std::array<float, N>& machs,
414 const std::array<float, N>&& drags) = delete;
415 template <size_t N>
416 Builder& MachVsDragTable(const std::array<float, N>&& machs,
417 const std::array<float, N>&& drags) = delete;
418
435 Builder& BCVelocityBands(const float* pfps, const float* pbcvs, size_t size) {
436 ::LobBuilderBCVelocityBands(&builder_, pfps, pbcvs, size);
437 return *this;
438 }
439
457 template <size_t N>
458 Builder& BCVelocityBands(const std::array<float, N>& fps,
459 const std::array<float, N>& bcvs) {
460 ::LobBuilderBCVelocityBands(&builder_, fps.data(), bcvs.data(), N);
461 return *this;
462 }
463 template <size_t N>
464 Builder& BCVelocityBands(const std::array<float, N>&& fps,
465 const std::array<float, N>& bcvs) = delete;
466 template <size_t N>
467 Builder& BCVelocityBands(const std::array<float, N>& fps,
468 const std::array<float, N>&& bcvs) = delete;
469 template <size_t N>
470 Builder& BCVelocityBands(const std::array<float, N>&& fps,
471 const std::array<float, N>&& bcvs) = delete;
472
478 Builder& MassGrains(double value) {
479 ::LobBuilderMassGrains(&builder_, value);
480 return *this;
481 }
482
488 Builder& InitialVelocityFps(uint16_t value) {
489 ::LobBuilderInitialVelocityFps(&builder_, value);
490 return *this;
491 }
492
498 Builder& OpticHeightInches(double value) {
499 ::LobBuilderOpticHeightInches(&builder_, value);
500 return *this;
501 }
502
510 ::LobBuilderTwistInchesPerTurn(&builder_, value);
511 return *this;
512 }
513
522 Builder& ZeroAngleMOA(double value) {
523 ::LobBuilderZeroAngleMOA(&builder_, value);
524 return *this;
525 }
526
532 Builder& ZeroDistanceYds(double value) {
533 ::LobBuilderZeroDistanceYds(&builder_, value);
534 return *this;
535 }
536
545 ::LobBuilderZeroImpactHeightInches(&builder_, value);
546 return *this;
547 }
548
555 ::LobBuilderAltitudeOfFiringSiteFt(&builder_, value);
556 return *this;
557 }
558
564 Builder& AirPressureInHg(double value) {
565 ::LobBuilderAirPressureInHg(&builder_, value);
566 return *this;
567 }
568
579 ::LobBuilderAltitudeOfBarometerFt(&builder_, value);
580 return *this;
581 }
582
588 Builder& TemperatureDegF(double value) {
589 ::LobBuilderTemperatureDegF(&builder_, value);
590 return *this;
591 }
592
603 ::LobBuilderAltitudeOfThermometerFt(&builder_, value);
604 return *this;
605 }
606
613 ::LobBuilderRelativeHumidityPercent(&builder_, value);
614 return *this;
615 }
616
624 ::LobBuilderWindHeading(&builder_, static_cast<::LobClockAngleT>(value));
625 return *this;
626 }
627
635 ::LobBuilderWindHeading(&builder_, value);
636 return *this;
637 }
638
645 Builder& WindHeadingDeg(double value) {
646 ::LobBuilderWindHeadingDeg(&builder_, value);
647 return *this;
648 }
649
655 Builder& WindSpeedFps(double value) {
656 ::LobBuilderWindSpeedFps(&builder_, value);
657 return *this;
658 }
659
665 Builder& WindSpeedMph(double value) {
666 ::LobBuilderWindSpeedMph(&builder_, value);
667 return *this;
668 }
669
676 Builder& AzimuthDeg(double value) {
677 ::LobBuilderAzimuthDeg(&builder_, value);
678 return *this;
679 }
680
687 Builder& LatitudeDeg(double value) {
688 ::LobBuilderLatitudeDeg(&builder_, value);
689 return *this;
690 }
691
697 Builder& RangeAngleDeg(double value) {
698 ::LobBuilderRangeAngleDeg(&builder_, value);
699 return *this;
700 }
701
708 Builder& MinimumSpeed(uint16_t value) {
709 ::LobBuilderMinimumSpeed(&builder_, value);
710 return *this;
711 }
712
719 Builder& MinimumEnergy(uint16_t value) {
720 ::LobBuilderMinimumEnergy(&builder_, value);
721 return *this;
722 }
723
730 Builder& MaximumTime(double value) {
731 ::LobBuilderMaximumTime(&builder_, value);
732 return *this;
733 }
734
741 Builder& StepSize(uint16_t value) {
742 ::LobBuilderStepSize(&builder_, value);
743 return *this;
744 }
745
750 Builder& Reset() noexcept {
751 ::LobBuilderReset(&builder_);
752 return *this;
753 }
754
760 Context result{};
761 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
762 ::LobBuilderBuild(&builder_, reinterpret_cast<::LobContext*>(&result));
763 return result;
764 }
765
766 private:
767 ::LobBuilder builder_;
768};
769
781inline size_t Solve(const Context& ctx, const uint32_t* pranges, Output* pouts,
782 size_t size) {
783 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
784 return ::LobSolve(reinterpret_cast<const ::LobContext*>(&ctx), pranges, pouts,
785 size);
786}
787
797template <size_t N>
798inline size_t Solve(const Context& ctx, const std::array<uint32_t, N>& ranges,
799 std::array<Output, N>* pouts) {
800 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
801 return ::LobSolve(reinterpret_cast<const ::LobContext*>(&ctx), ranges.data(),
802 pouts->data(), N);
803}
804
813inline size_t Solve(const Context& ctx, uint32_t range, Output* pout) {
814 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
815 return ::LobSolve(reinterpret_cast<const ::LobContext*>(&ctx), &range, pout,
816 1);
817}
818
831inline size_t FastInverse(const Context& ctx, Output* pouts, size_t size) {
832 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
833 return ::LobFastInverse(reinterpret_cast<const ::LobContext*>(&ctx), pouts,
834 size);
835}
836
847template <size_t N>
848inline size_t FastInverse(const Context& ctx, std::array<Output, N>* pouts) {
849 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
850 return ::LobFastInverse(reinterpret_cast<const ::LobContext*>(&ctx),
851 pouts->data(), N);
852}
853
861inline size_t FastInverse(const Context& ctx, Output* pout) {
862 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
863 return ::LobFastInverse(reinterpret_cast<const ::LobContext*>(&ctx), pout, 1);
864}
865
881inline size_t SolveInverse(const Context& ctx, const uint32_t* pranges,
882 Output* pouts, size_t size) {
883 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
884 return ::LobSolveInverse(reinterpret_cast<const ::LobContext*>(&ctx), pranges,
885 pouts, size);
886}
887
897template <size_t N>
898inline size_t SolveInverse(const Context& ctx,
899 const std::array<uint32_t, N>& ranges,
900 std::array<Output, N>* pouts) {
901 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
902 return ::LobSolveInverse(reinterpret_cast<const ::LobContext*>(&ctx),
903 ranges.data(), pouts->data(), N);
904}
905
914inline size_t SolveInverse(const Context& ctx, uint32_t range, Output* pout) {
915 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
916 return ::LobSolveInverse(reinterpret_cast<const ::LobContext*>(&ctx), &range,
917 pout, 1);
918}
919
924inline const char* Version() { return ::LobVersion(); }
925
931inline double MoaToMil(double value) { return ::LobMoaToMil(value); }
937inline double MoaToDeg(double value) { return ::LobMoaToDeg(value); }
943inline double MoaToIphy(double value) { return ::LobMoaToIphy(value); }
951inline double MoaToInch(double value, double range_ft) {
952 return ::LobMoaToInch(value, range_ft);
953}
954
960inline double MilToMoa(double value) { return ::LobMilToMoa(value); }
966inline double MilToDeg(double value) { return ::LobMilToDeg(value); }
972inline double MilToIphy(double value) { return ::LobMilToIphy(value); }
980inline double MilToInch(double value, double range_ft) {
981 return ::LobMilToInch(value, range_ft);
982}
983
989inline double DegToMoa(double value) { return ::LobDegToMoa(value); }
995inline double DegToMil(double value) { return ::LobDegToMil(value); }
996
1003inline double InchToMoa(double value, double range_ft) {
1004 return ::LobInchToMoa(value, range_ft);
1005}
1006
1012inline double InchToMil(double value, double range_ft) {
1013 return ::LobInchToMil(value, range_ft);
1014}
1015
1021inline double InchToDeg(double value, double range_ft) {
1022 return ::LobInchToDeg(value, range_ft);
1023}
1024
1030inline double JToFtLbs(double value) { return ::LobJToFtLbs(value); }
1036inline double FtLbsToJ(double value) { return ::LobFtLbsToJ(value); }
1037
1043inline double MToYd(double value) { return ::LobMToYd(value); }
1044
1050inline double YdToFt(double value) { return ::LobYdToFt(value); }
1056inline double MToFt(double value) { return ::LobMToFt(value); }
1062inline double FtToIn(double value) { return ::LobFtToIn(value); }
1068inline double MmToIn(double value) { return ::LobMmToIn(value); }
1074inline double CmToIn(double value) { return ::LobCmToIn(value); }
1080inline double YdToM(double value) { return ::LobYdToM(value); }
1086inline double FtToM(double value) { return ::LobFtToM(value); }
1092inline double FtToYd(double value) { return ::LobFtToYd(value); }
1098inline double InToMm(double value) { return ::LobInToMm(value); }
1104inline double InToCm(double value) { return ::LobInToCm(value); }
1110inline double InToFt(double value) { return ::LobInToFt(value); }
1111
1117inline double PaToInHg(double value) { return ::LobPaToInHg(value); }
1123inline double MbarToInHg(double value) { return ::LobMbarToInHg(value); }
1129inline double PsiToInHg(double value) { return ::LobPsiToInHg(value); }
1130
1136inline double LbsToGrain(double value) { return ::LobLbsToGrain(value); }
1142inline double GToGrain(double value) { return ::LobGToGrain(value); }
1148inline double KgToGrain(double value) { return ::LobKgToGrain(value); }
1149
1155inline double KgSqMToPmsi(double value) { return ::LobKgSqMToPmsi(value); }
1156
1162inline double FpsToMps(double value) { return ::LobFpsToMps(value); }
1168inline double MpsToFps(double value) { return ::LobMpsToFps(value); }
1174inline double KphToMph(double value) { return ::LobKphToMph(value); }
1180inline double KnToMph(double value) { return ::LobKnToMph(value); }
1181
1187inline double MsToS(double value) { return ::LobMsToS(value); }
1193inline double UsToS(double value) { return ::LobUsToS(value); }
1199inline double SToMs(double value) { return ::LobSToMs(value); }
1205inline double SToUs(double value) { return ::LobSToUs(value); }
1206
1212inline double DegCToDegF(double value) { return ::LobDegCToDegF(value); }
1213
1214} // namespace lob
1215
1216// This file is part of lob.
1217//
1218// lob is free software: you can redistribute it and/or modify it under the
1219// terms of the GNU General Public License as published by the Free Software
1220// Foundation, either version 3 of the License, or (at your option) any later
1221// version.
1222//
1223// lob is distributed in the hope that it will be useful, but WITHOUT ANY
1224// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
1225// A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1226//
1227// You should have received a copy of the GNU General Public License along with
1228// lob. If not, see <https://www.gnu.org/licenses/>.
Context Build()
Builds the Context object with the configured parameters.
Definition lob.hpp:759
Builder & WindHeadingDeg(double value)
Sets the wind heading in degrees.
Definition lob.hpp:645
Builder & LengthInch(double value)
Sets the projectile length in inches.
Definition lob.hpp:330
Builder & TemperatureDegF(double value)
Sets the temperature in degrees Fahrenheit.
Definition lob.hpp:588
Builder & ZeroAngleMOA(double value)
Sets the angle between the sight and launch angle used to achieve zero.
Definition lob.hpp:522
Builder & operator=(const Builder &rhs)
Copy assignment operator.
Definition lob.hpp:219
Builder & BCVelocityBands(const std::array< float, N > &&fps, const std::array< float, N > &&bcvs)=delete
Builder & BCAtmosphere(LobAtmosphereReferenceT type)
Sets the atmosphere reference associated with ballistic coefficient.
Definition lob.hpp:261
Builder & MachVsDragTable(const std::array< float, N > &&machs, const std::array< float, N > &&drags)=delete
Builder & MaximumTime(double value)
Sets the maximum time of flight for the solver.
Definition lob.hpp:730
Builder & MassGrains(double value)
Sets the projectile mass in grains.
Definition lob.hpp:478
Builder & AzimuthDeg(double value)
Sets the azimuth (bearing) of the target in degrees.
Definition lob.hpp:676
Builder & BCVelocityBands(const std::array< float, N > &&fps, const std::array< float, N > &bcvs)=delete
Builder & TailLengthInch(double value)
Sets the projectile tail length in inches.
Definition lob.hpp:350
Builder & operator=(Builder &&rhs) noexcept
Move assignment operator.
Definition lob.hpp:227
Builder & BCVelocityBands(const std::array< float, N > &fps, const std::array< float, N > &bcvs)
Loads ballistic coefficients measured at multiple velocities.
Definition lob.hpp:458
Builder & InitialVelocityFps(uint16_t value)
Sets the initial velocity of the projectile in feet per second.
Definition lob.hpp:488
Builder & AltitudeOfFiringSiteFt(double value)
Sets the altitude of the firing site in feet.
Definition lob.hpp:554
Builder & MeplatDiameterInch(double value)
Sets the projectile meplat diameter in inches.
Definition lob.hpp:310
Builder & MinimumEnergy(uint16_t value)
Sets the minimum energy threshold for the solver.
Definition lob.hpp:719
Builder & BallisticCoefficientPsi(double value)
Sets the ballistic coefficient (Psi).
Definition lob.hpp:240
Builder & AirPressureInHg(double value)
Sets the air pressure in inches of mercury (inHg).
Definition lob.hpp:564
~Builder()
Destructor.
Definition lob.hpp:207
Builder & DiameterInch(double value)
Sets the projectile diameter (caliber) in inches.
Definition lob.hpp:300
Builder & WindHeading(LobClockAngleT value)
Sets the wind heading using a clock angle.
Definition lob.hpp:634
Builder & MachVsDragTable(const std::array< float, N > &&machs, const std::array< float, N > &drags)=delete
Builder & WindHeading(ClockAngleT value)
Sets the wind heading using a clock angle.
Definition lob.hpp:623
Builder & MachVsDragTable(const std::array< float, N > &machs, const std::array< float, N > &drags)
Loads a custom Mach vs Drag table for the projectile.
Definition lob.hpp:404
Builder & LatitudeDeg(double value)
Sets the latitude of the firing location in degrees.
Definition lob.hpp:687
Builder & OpticHeightInches(double value)
Sets the height of the optic above the bore in inches.
Definition lob.hpp:498
Builder & BCAtmosphere(AtmosphereReferenceT type)
Sets the atmosphere reference associated with ballistic coefficient.
Definition lob.hpp:250
Builder & BCVelocityBands(const float *pfps, const float *pbcvs, size_t size)
Loads ballistic coefficients measured at multiple velocities.
Definition lob.hpp:435
Builder & Reset() noexcept
Resets the builder state by re-initializing.
Definition lob.hpp:750
Builder & ZeroDistanceYds(double value)
Sets the zero distance in yards.
Definition lob.hpp:532
Builder()
Default constructor.
Definition lob.hpp:204
Builder & MinimumSpeed(uint16_t value)
Sets the minimum speed threshold for the solver.
Definition lob.hpp:708
Builder & RangeAngleDeg(double value)
Sets the range angle (inclination) to the target in degrees.
Definition lob.hpp:697
Builder & MachVsDragTable(const std::array< float, N > &machs, const std::array< float, N > &&drags)=delete
Builder(const Builder &other)
Definition lob.hpp:209
Builder & WindSpeedMph(double value)
Sets the wind speed in miles per hour.
Definition lob.hpp:665
Builder & BCDragFunction(DragFunctionT type)
Sets the drag function associated with ballistic coefficient.
Definition lob.hpp:275
Builder & BCVelocityBands(const std::array< float, N > &fps, const std::array< float, N > &&bcvs)=delete
Builder & ZeroImpactHeightInches(double value)
Sets the zero impact height in inches.
Definition lob.hpp:544
Builder(Builder &&other) noexcept
Definition lob.hpp:213
Builder & NoseLengthInch(double value)
Sets the projectile nose length in inches.
Definition lob.hpp:340
Builder & AltitudeOfBarometerFt(double value)
Sets the altitude of the location where air pressure was taken in feet.
Definition lob.hpp:578
Builder & OgiveRtR(double value)
Sets the Rt/R ratio of the projectile ogive.
Definition lob.hpp:360
Builder & TwistInchesPerTurn(double value)
Sets the twist rate of the barrel in inches per turn.
Definition lob.hpp:509
Builder & WindSpeedFps(double value)
Sets the wind speed in feet per second.
Definition lob.hpp:655
Builder & StepSize(uint16_t value)
Sets the step size for the numerical solver.
Definition lob.hpp:741
Builder & MachVsDragTable(const float *pmachs, const float *pdrags, size_t size)
Loads a custom Mach vs Drag table for the projectile.
Definition lob.hpp:381
Builder & BaseDiameterInch(double value)
Sets the projectile base diameter in inches.
Definition lob.hpp:320
Builder & RelativeHumidityPercent(double value)
Sets the relative humidity at the firing site in percent.
Definition lob.hpp:612
Builder & BCDragFunction(LobDragFunctionT type)
Sets the drag function associated with ballistic coefficient.
Definition lob.hpp:290
Builder & AltitudeOfThermometerFt(double value)
Sets the altitude of the location where temperature was taken in feet.
Definition lob.hpp:602
LobBuilder * LobBuilderAzimuthDeg(LobBuilder *pbuilder, double value)
Sets the azimuth (bearing) of the target in degrees.
void LobBuilderInit(LobBuilder *pbuilder)
Initializes a builder to default state. No-op if pbuilder is null.
LobBuilder * LobBuilderWindSpeedFps(LobBuilder *pbuilder, double value)
Sets the wind speed in feet per second.
LobBuilder * LobBuilderTemperatureDegF(LobBuilder *pbuilder, double value)
Sets the temperature in degrees Fahrenheit.
LobBuilder * LobBuilderTailLengthInch(LobBuilder *pbuilder, double value)
Sets the projectile tail length in inches.
LobBuilder * LobBuilderOpticHeightInches(LobBuilder *pbuilder, double value)
Sets the height of the optic above the bore in inches.
#define LOB_BUILDER_BUFFER_SIZE
The size in bytes of the builder buffer.
Definition lob.h:21
LobBuilder * LobBuilderAirPressureInHg(LobBuilder *pbuilder, double value)
Sets the air pressure in inches of mercury (inHg).
LobBuilder * LobBuilderMinimumEnergy(LobBuilder *pbuilder, uint16_t value)
Sets the minimum energy threshold for the solver.
LobBuilder * LobBuilderRelativeHumidityPercent(LobBuilder *pbuilder, double value)
Sets the relative humidity at the firing site in percent.
uint8_t LobClockAngleT
Clock angle positions for wind direction.
Definition lob.h:43
LobBuilder * LobBuilderDiameterInch(LobBuilder *pbuilder, double value)
Sets the projectile diameter (caliber) in inches.
LobBuilder * LobBuilderBCAtmosphere(LobBuilder *pbuilder, LobAtmosphereReferenceT type)
Sets the atmosphere reference associated with ballistic coefficient.
LobBuilder * LobBuilderLengthInch(LobBuilder *pbuilder, double value)
Sets the projectile length in inches.
LobBuilder * LobBuilderTwistInchesPerTurn(LobBuilder *pbuilder, double value)
Sets the twist rate of the barrel in inches per turn.
LobBuilder * LobBuilderBCVelocityBands(LobBuilder *pbuilder, const float *pfps, const float *pbcs, size_t size)
Loads ballistic coefficients measured at multiple velocities.
uint8_t LobAtmosphereReferenceT
Atmosphere reference type.
Definition lob.h:35
LobBuilder * LobBuilderReset(LobBuilder *pbuilder)
Resets a builder state by re-initializing. No-op if pbuilder is null.
LobBuilder * LobBuilderLatitudeDeg(LobBuilder *pbuilder, double value)
Sets the latitude of the firing location in degrees.
LobBuilder * LobBuilderBCDragFunction(LobBuilder *pbuilder, LobDragFunctionT type)
Sets the drag function associated with ballistic coefficient.
LobBuilder * LobBuilderMaximumTime(LobBuilder *pbuilder, double value)
Sets the maximum time of flight for the solver.
@ kLobDragFunctionG2
G2 drag function.
Definition lob.h:27
@ kLobDragFunctionG1
G1 drag function.
Definition lob.h:26
@ kLobDragFunctionG7
G7 drag function.
Definition lob.h:30
@ kLobDragFunctionG6
G6 drag function.
Definition lob.h:29
@ kLobDragFunctionG8
G8 drag function.
Definition lob.h:31
@ kLobDragFunctionG5
G5 drag function.
Definition lob.h:28
LobBuilder * LobBuilderOgiveRtR(LobBuilder *pbuilder, double value)
Sets the Rt/R ratio of the projectile ogive.
@ kLobErrorDiameterOOR
Definition lob.h:74
@ kLobErrorNotFormed
Definition lob.h:87
@ kLobErrorMeplatDiameterOOR
Definition lob.h:85
@ kLobErrorMachDragTableNotMonotonic
Definition lob.h:81
@ kLobErrorBaseDiameterOOR
Definition lob.h:70
@ kLobErrorLatitudeOOR
Definition lob.h:78
@ kLobErrorInternalError
Definition lob.h:77
@ kLobErrorNoseLengthOOR
Definition lob.h:86
@ kLobErrorBallisticCoefficientOOR
Definition lob.h:68
@ kLobErrorZeroAngleOOR
Definition lob.h:92
@ kLobErrorLengthOOR
Definition lob.h:79
@ kLobErrorZeroUnreachable
Definition lob.h:95
@ kLobErrorOgiveRtROOR
Definition lob.h:88
@ kLobErrorMachDragTableTooShort
Definition lob.h:82
@ kLobErrorRangeAngleOOR
Definition lob.h:89
@ kLobErrorZeroDataRequired
Definition lob.h:93
@ kLobErrorMaximumTimeOOR
Definition lob.h:84
@ kLobErrorTailLengthOOR
Definition lob.h:90
@ kLobErrorBallisticCoefficientRequired
Definition lob.h:69
@ kLobErrorBcBandsInvalid
Definition lob.h:71
@ kLobErrorAirPressureOOR
Definition lob.h:63
@ kLobErrorInitialVelocityRequired
Definition lob.h:76
@ kLobErrorNone
Definition lob.h:62
@ kLobErrorHumidityOOR
Definition lob.h:75
@ kLobErrorAzimuthOOR
Definition lob.h:67
@ kLobErrorMassOOR
Definition lob.h:83
@ kLobErrorZeroDistanceOOR
Definition lob.h:94
@ kLobErrorWindHeadingOOR
Definition lob.h:91
@ kLobErrorAltitudeOfThermometerOOR
Definition lob.h:66
@ kLobErrorBcBandsTooShort
Definition lob.h:73
@ kLobErrorMachDragTableInvalid
Definition lob.h:80
@ kLobErrorBcBandsNotMonotonic
Definition lob.h:72
@ kLobErrorAltitudeOfBarometerOOR
Definition lob.h:64
@ kLobErrorAltitudeOfFiringSiteOOR
Definition lob.h:65
LobBuilder * LobBuilderZeroAngleMOA(LobBuilder *pbuilder, double value)
Sets the angle between the sight and launch angle used to achieve zero.
#define LOB_SPLINE_SEGMENTS
The number of spline pieces comprising a drag function.
Definition lob.h:19
LobBuilder * LobBuilderAltitudeOfThermometerFt(LobBuilder *pbuilder, double value)
Sets the altitude of the location where temperature was taken in feet.
@ kLobClockAngleVIII
eight o'clock
Definition lob.h:52
@ kLobClockAngleIV
four o'clock
Definition lob.h:48
@ kLobClockAngleV
five o'clock
Definition lob.h:49
@ kLobClockAngleI
one o'clock
Definition lob.h:45
@ kLobClockAngleVI
six o'clock
Definition lob.h:50
@ kLobClockAngleXI
eleven o'clock
Definition lob.h:55
@ kLobClockAngleVII
seven o'clock
Definition lob.h:51
@ kLobClockAngleII
two o'clock
Definition lob.h:46
@ kLobClockAngleIII
three o'clock
Definition lob.h:47
@ kLobClockAngleXII
twelve o'clock
Definition lob.h:56
@ kLobClockAngleX
ten o'clock
Definition lob.h:54
@ kLobClockAngleIX
nine o'clock
Definition lob.h:53
uint8_t LobDragFunctionT
Drag function type.
Definition lob.h:24
@ kLobAtmosphereReferenceArmyStandardMetro
Army Standard Metro.
Definition lob.h:37
@ kLobAtmosphereReferenceIcao
International Civil Aviation Organization (ICAO)
Definition lob.h:38
LobBuilder * LobBuilderSplineFitTable(LobBuilder *pbuilder, const float *pmachs, const float *pdrags, size_t size)
Loads a custom Mach vs Drag table for the projectile.
void LobBuilderBuild(LobBuilder *pbuilder, LobContext *presult)
Builds the LobContext object with the configured parameters.
LobBuilder * LobBuilderRangeAngleDeg(LobBuilder *pbuilder, double value)
Sets the range angle (inclination) to the target in degrees.
LobBuilder * LobBuilderStepSize(LobBuilder *pbuilder, uint16_t value)
Sets the step size for the numerical solver.
LobBuilder * LobBuilderZeroImpactHeightInches(LobBuilder *pbuilder, double value)
Sets the zero impact height in inches.
uint8_t LobErrorT
Error codes returned by the builder.
Definition lob.h:60
LobBuilder * LobBuilderBallisticCoefficientPsi(LobBuilder *pbuilder, double value)
Sets the ballistic coefficient (Psi).
LobBuilder * LobBuilderAltitudeOfFiringSiteFt(LobBuilder *pbuilder, double value)
Sets the altitude of the firing site in feet.
LobBuilder * LobBuilderMinimumSpeed(LobBuilder *pbuilder, uint16_t value)
Sets the minimum speed threshold for the solver.
LobBuilder * LobBuilderZeroDistanceYds(LobBuilder *pbuilder, double value)
Sets the zero distance in yards.
LobBuilder * LobBuilderNoseLengthInch(LobBuilder *pbuilder, double value)
Sets the projectile nose length in inches.
LobBuilder * LobBuilderInitialVelocityFps(LobBuilder *pbuilder, uint16_t value)
Sets the initial velocity of the projectile in feet per second.
LobBuilder * LobBuilderMeplatDiameterInch(LobBuilder *pbuilder, double value)
Sets the projectile meplat diameter in inches.
LobBuilder * LobBuilderWindHeadingDeg(LobBuilder *pbuilder, double value)
Sets the wind heading in degrees.
LobBuilder * LobBuilderAltitudeOfBarometerFt(LobBuilder *pbuilder, double value)
Sets the altitude of the location where air pressure was taken in feet.
LobBuilder * LobBuilderMassGrains(LobBuilder *pbuilder, double value)
Sets the projectile mass in grains.
LobBuilder * LobBuilderWindHeading(LobBuilder *pbuilder, LobClockAngleT value)
Sets the wind heading using a clock angle.
void LobBuilderCopy(LobBuilder *dst, const LobBuilder *src)
Copies builder state from src to dst. No-op if either is null.
LobBuilder * LobBuilderBaseDiameterInch(LobBuilder *pbuilder, double value)
Sets the projectile base diameter in inches.
void LobBuilderDestroy(LobBuilder *pbuilder)
Destroys a builder and releases resources. No-op if pbuilder is null.
LobBuilder * LobBuilderWindSpeedMph(LobBuilder *pbuilder, double value)
Sets the wind speed in miles per hour.
Definition lob.hpp:13
size_t FastInverse(const Context &ctx, Output *pouts, size_t size)
Converts forward-solution output to inverse-solution adjustments.
Definition lob.hpp:831
double MilToDeg(double value)
Converts milliradians (MIL) to degrees.
Definition lob.hpp:966
double InToMm(double value)
Converts inches to millimeters.
Definition lob.hpp:1098
double YdToFt(double value)
Converts yards to feet.
Definition lob.hpp:1050
double GToGrain(double value)
Converts grams to grains.
Definition lob.hpp:1142
bool operator==(::LobErrorT a, ErrorT b) noexcept
Definition lob.hpp:185
double MoaToMil(double value)
Converts minutes of angle (MOA) to milliradians (MIL).
Definition lob.hpp:931
double KgToGrain(double value)
Converts kilograms to grains.
Definition lob.hpp:1148
double KnToMph(double value)
Converts Knots to miles per hour.
Definition lob.hpp:1180
double DegCToDegF(double value)
Converts degrees celsius to degrees fahrenheit.
Definition lob.hpp:1212
double KgSqMToPmsi(double value)
Converts kilograms per square meter to pounds mass per square inch.
Definition lob.hpp:1155
double JToFtLbs(double value)
Converts joules to foot-pounds.
Definition lob.hpp:1030
AtmosphereReferenceT
Enumerates the supported atmosphere reference types.
Definition lob.hpp:31
@ kArmyStandardMetro
Army Standard Metro.
Definition lob.hpp:32
@ kIcao
International Civil Aviation Organization (ICAO)
Definition lob.hpp:35
double KphToMph(double value)
Converts kilometers per hour to miles per hour.
Definition lob.hpp:1174
double LbsToGrain(double value)
Converts pounds to grains.
Definition lob.hpp:1136
double PsiToInHg(double value)
Converts pounds per square inch (PSI) to inches of mercury.
Definition lob.hpp:1129
double PaToInHg(double value)
Converts pascals to inches of mercury.
Definition lob.hpp:1117
::LobCoriolis Coriolis
Coriolis effect parameters. See LobCoriolis for member details.
Definition lob.hpp:102
double CmToIn(double value)
Converts centimeters to inches.
Definition lob.hpp:1074
double MToYd(double value)
Converts meters to yards.
Definition lob.hpp:1043
::LobOutput Output
Structure holding output results. See LobOutput for member details.
Definition lob.hpp:183
double MmToIn(double value)
Converts millimeters to inches.
Definition lob.hpp:1068
double MbarToInHg(double value)
Converts millibars to inches of mercury.
Definition lob.hpp:1123
double MoaToDeg(double value)
Converts minutes of angle (MOA) to degrees.
Definition lob.hpp:937
::LobGravity Gravity
Gravity vector. See LobGravity for member details.
Definition lob.hpp:98
double FtToYd(double value)
Converts feet to yards.
Definition lob.hpp:1092
double MilToIphy(double value)
Converts milliradians (MIL) to inches per hundred yards (IPHY).
Definition lob.hpp:972
double MpsToFps(double value)
Converts meters per second to feet per second.
Definition lob.hpp:1168
ErrorT
Error codes returned by the builder.
Definition lob.hpp:60
@ kOgiveRtROOR
Definition lob.hpp:87
@ kBaseDiameterOOR
Definition lob.hpp:69
@ kMeplatDiameterOOR
Definition lob.hpp:84
@ kZeroDistanceOOR
Definition lob.hpp:93
@ kAzimuthOOR
Definition lob.hpp:66
@ kMachDragTableTooShort
Definition lob.hpp:81
@ kNotFormed
Definition lob.hpp:86
@ kBallisticCoefficientOOR
Definition lob.hpp:67
@ kNone
Definition lob.hpp:61
@ kTailLengthOOR
Definition lob.hpp:89
@ kMaximumTimeOOR
Definition lob.hpp:83
@ kMachDragTableNotMonotonic
Definition lob.hpp:80
@ kAltitudeOfBarometerOOR
Definition lob.hpp:63
@ kHumidityOOR
Definition lob.hpp:74
@ kBcBandsTooShort
Definition lob.hpp:72
@ kWindHeadingOOR
Definition lob.hpp:90
@ kBcBandsNotMonotonic
Definition lob.hpp:71
@ kInitialVelocityRequired
Definition lob.hpp:75
@ kDiameterOOR
Definition lob.hpp:73
@ kLengthOOR
Definition lob.hpp:78
@ kAltitudeOfThermometerOOR
Definition lob.hpp:65
@ kAltitudeOfFiringSiteOOR
Definition lob.hpp:64
@ kBallisticCoefficientRequired
Definition lob.hpp:68
@ kNoseLengthOOR
Definition lob.hpp:85
@ kMassOOR
Definition lob.hpp:82
@ kZeroUnreachable
Definition lob.hpp:94
@ kZeroDataRequired
Definition lob.hpp:92
@ kZeroAngleOOR
Definition lob.hpp:91
@ kRangeAngleOOR
Definition lob.hpp:88
@ kAirPressureOOR
Definition lob.hpp:62
@ kLatitudeOOR
Definition lob.hpp:77
@ kMachDragTableInvalid
Definition lob.hpp:79
@ kInternalError
Definition lob.hpp:76
@ kBcBandsInvalid
Definition lob.hpp:70
double InToCm(double value)
Converts inches to centimeters.
Definition lob.hpp:1104
double MoaToInch(double value, double range_ft)
Converts minutes of angle (MOA) to projected inches at a given range in feet.
Definition lob.hpp:951
double InchToMil(double value, double range_ft)
Inches of projection at a given range to milliradians (MIL).
Definition lob.hpp:1012
double FtToM(double value)
Converts feet to meters.
Definition lob.hpp:1086
ClockAngleT
Enumerates clock angle positions.
Definition lob.hpp:44
@ kX
ten o'clock
Definition lob.hpp:54
@ kI
one o'clock
Definition lob.hpp:45
@ kXI
eleven o'clock
Definition lob.hpp:55
@ kVII
seven o'clock
Definition lob.hpp:51
@ kVIII
eight o'clock
Definition lob.hpp:52
@ kV
five o'clock
Definition lob.hpp:49
@ kVI
six o'clock
Definition lob.hpp:50
@ kIV
four o'clock
Definition lob.hpp:48
@ kIII
three o'clock
Definition lob.hpp:47
@ kIX
nine o'clock
Definition lob.hpp:53
@ kXII
twelve o'clock
Definition lob.hpp:56
@ kII
two o'clock
Definition lob.hpp:46
size_t Solve(const Context &ctx, const uint32_t *pranges, Output *pouts, size_t size)
Solves the exterior ballistics problem for a given set of ranges. Results contain a forward-solution.
Definition lob.hpp:781
double DegToMil(double value)
Converts degrees to milliradians (MIL).
Definition lob.hpp:995
double MilToMoa(double value)
Converts milliradians (MIL) to minutes of angle (MOA).
Definition lob.hpp:960
DragFunctionT
Enumerates the supported drag functions.
Definition lob.hpp:21
@ kG2
G2 drag function.
Definition lob.hpp:23
@ kG5
G5 drag function.
Definition lob.hpp:24
@ kG1
G1 drag function.
Definition lob.hpp:22
@ kG8
G8 drag function.
Definition lob.hpp:27
@ kG7
G7 drag function.
Definition lob.hpp:26
@ kG6
G6 drag function.
Definition lob.hpp:25
double InToFt(double value)
Converts inches to feet.
Definition lob.hpp:1110
double FtToIn(double value)
Converts feet to inches.
Definition lob.hpp:1062
double FtLbsToJ(double value)
Converts foot-pounds to joules.
Definition lob.hpp:1036
bool operator!=(::LobErrorT a, ErrorT b) noexcept
Definition lob.hpp:188
double SToUs(double value)
Converts seconds to microseconds.
Definition lob.hpp:1205
double InchToMoa(double value, double range_ft)
Inches of projection at a given range to minutes of angle (MOA).
Definition lob.hpp:1003
double MsToS(double value)
Converts milliseconds to seconds.
Definition lob.hpp:1187
double YdToM(double value)
Converts yards to meters.
Definition lob.hpp:1080
double MilToInch(double value, double range_ft)
Converts milliradians (MIL) to projected inches at a given range in feet.
Definition lob.hpp:980
double InchToDeg(double value, double range_ft)
Inches of projection at a given range to degrees.
Definition lob.hpp:1021
constexpr size_t kLobCoeffsSize
The size of spline coeffs in Context.
Definition lob.hpp:18
const char * Version()
Gets the library version in major.minor.patch format.
Definition lob.hpp:924
constexpr size_t kLobBuilderBufferSize
The size in bytes of the builder buffer.
Definition lob.hpp:16
double SToMs(double value)
Converts seconds to milliseconds.
Definition lob.hpp:1199
size_t SolveInverse(const Context &ctx, const uint32_t *pranges, Output *pouts, size_t size)
Solves the exterior ballistics problem for a given set of ranges. Results contain an inverse-solution...
Definition lob.hpp:881
double UsToS(double value)
Converts microseconds to seconds.
Definition lob.hpp:1193
double MoaToIphy(double value)
Converts minutes of angle (MOA) to inches per hundred yards (IPHY).
Definition lob.hpp:943
::LobWind Wind
Wind vector. See LobWind for member details.
Definition lob.hpp:100
double MToFt(double value)
Converts meters to feet.
Definition lob.hpp:1056
double FpsToMps(double value)
Converts feet per second to meters per second.
Definition lob.hpp:1162
double DegToMoa(double value)
Converts degrees to minutes of angle (MOA).
Definition lob.hpp:989
Opaque builder type for constructing LobContext objects.
Definition lob.h:158
Structure of parameters consumed by the solver.
Definition lob.h:123
Coriolis effect parameters.
Definition lob.h:112
Gravity vector.
Definition lob.h:100
Structure holding the output results of a ballistic calculation.
Definition lob.h:145
Wind vector.
Definition lob.h:106
Structure of parameters consumed by the solver.
Definition lob.hpp:108
double speed_of_sound
The local speed of sound in Fps.
Definition lob.hpp:110
double stability_factor
Miller stability factor.
Definition lob.hpp:117
double mass
Mass of the projectile in pounds.
Definition lob.hpp:111
double zero_angle
Angle between sight and trajectory.
Definition lob.hpp:116
double spindrift_factor
Spin drift factor.
Definition lob.hpp:119
std::array< float, kLobCoeffsSize > drags
Drag curve coefficients.
Definition lob.hpp:122
uint16_t minimum_speed
Minimum speed for solver.
Definition lob.hpp:124
double optic_height
Height of the optic above the bore.
Definition lob.hpp:112
uint16_t velocity
Initial velocity of projectile in Fps.
Definition lob.hpp:123
Gravity gravity
Gravity vector.
Definition lob.hpp:113
double aerodynamic_jump
Aerodynamic jump effect in Moa.
Definition lob.hpp:118
uint16_t step_size
Solver step size in inches.
Definition lob.hpp:125
Wind wind
Wind vector.
Definition lob.hpp:114
double k_lapse
Projected linear density lapse coeff.
Definition lob.hpp:120
Coriolis coriolis
Coriolis effect parameters.
Definition lob.hpp:115
double max_time
Max time of flight for solver.
Definition lob.hpp:121
double drag_coeff
Drag coefficient scaling factor.
Definition lob.hpp:109
ErrorT error
Error status after build.
Definition lob.hpp:126