Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ On my honor, I will do my best to do my duty to God and my country and to obey t

## The Scout Law
A Scout is:
* Trustworthy,
* Loyal,
* Helpful,
* Friendly,
* Courteous,
* Kind,
* Obedient,
* Cheerful,
* Thrifty,
* Brave,
* Clean,
* and Reverent.
* Trustworthy
* Loyal
* Helpful
* Friendly
* Courteous
* Kind
* Obedient
* Cheerful
* Thrifty
* Brave
* Clean
* Reverent
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The following can be accounted for in lob's solutions:
* Gyroscopic spin drift
* Aerodynamic jump

In addition to ballistic solutions, lob provides some of the instrumental values it calculates which may be useful including the local speed of sound, stability factor, and the "zero angle" between the line of sight and line of fire. All native units are customary American freedom units :us: but a collection of unit conversion functions are included :hammer_and_wrench:
In addition to ballistic solutions, lob provides some of the instrumental values it calculates which may be useful including the local speed of sound, stability factor, and the "zero angle" between the line of sight and line of fire. All native units are customary American freedom units :statue_of_liberty: but a collection of unit conversion functions are included :hammer_and_wrench:

This repo includes a tiny example CLI program, lobber, which demonstrates the library's use. It's actually pretty handy!

Expand Down Expand Up @@ -136,4 +136,4 @@ See the [CONTRIBUTING](CONTRIBUTING.md) document.

See the [COPYING](COPYING) document.

:us: Hey, American company, you'd love to use lob but require a commercial license? [Raise an issue](https://github.com/joelbenway/lob/issues) to get in touch! Lob will help you hit your target! :rocket:
:eagle: Hey, American company, you'd love to use lob but require a commercial license? [Raise an issue](https://github.com/joelbenway/lob/issues) to get in touch! Lob will help you hit your target! :rocket:
6 changes: 6 additions & 0 deletions include/lob/lob.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,12 @@ class LOB_EXPORT Builder {
*/
Builder& Reset() noexcept;

/**
* @brief Checks if the current builder state is well-formed.
* @return True if state is valid, false otherwise.
*/
bool IsValid() const;

/**
* @brief Builds the `Input` object with the configured parameters.
* @return The constructed `Input` object.
Expand Down
18 changes: 10 additions & 8 deletions source/lob_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,16 +429,18 @@ Builder& Builder::Reset() noexcept {
return *this;
}

namespace {
bool ValidateBuild(const Impl& impl) {
const bool kErrorIsInExpectedState = impl.build.error == ErrorT::kNotFormed;
const bool kBCisOk = !impl.ballistic_coefficient_psi.IsNaN();
const bool kVelocityIsOk = impl.build.velocity > 0;
const bool kZeroIsOk =
!impl.zero_distance_ft.IsNaN() || !std::isnan(impl.build.zero_angle);
bool Builder::IsValid() const {
const bool kErrorIsInExpectedState =
pimpl_->build.error == ErrorT::kNotFormed ||
pimpl_->build.error == ErrorT::kNone;
const bool kBCisOk = !pimpl_->ballistic_coefficient_psi.IsNaN();
const bool kVelocityIsOk = pimpl_->build.velocity > 0;
const bool kZeroIsOk = !pimpl_->zero_distance_ft.IsNaN() ||
!std::isnan(pimpl_->build.zero_angle);
return kErrorIsInExpectedState && kBCisOk && kVelocityIsOk && kZeroIsOk;
}

namespace {
void BuildEnvironment(Impl* pimpl) {
assert(pimpl != nullptr);
FeetT altitude_of_firing_site = FeetT(0);
Expand Down Expand Up @@ -782,7 +784,7 @@ Input Builder::Build() {
if (pimpl_->build.error == ErrorT::kNone) {
pimpl_->build.error = ErrorT::kNotFormed;
}
if (ValidateBuild(*pimpl_)) {
if (IsValid()) {
// This order matters
BuildEnvironment(pimpl_);
BuildTable(pimpl_);
Expand Down
Loading