Skip to content

Commit

Permalink
Added translation for atan2
Browse files Browse the repository at this point in the history
  • Loading branch information
ZCG-coder committed Nov 19, 2024
1 parent d2e9796 commit 905d6fb
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 4 deletions.
30 changes: 30 additions & 0 deletions res/translations/atan2.stp_strings

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions res/translations/en-US/atan2.stp_localized

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions res/translations/zh-HK/atan2.stp_localized

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 20 additions & 4 deletions src/calc/atan2/atan2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
* @date 2nd August 2024
*/

#include "argParse.hpp"
#include "atan2Report.hpp"
#include "constants.hpp"
#include "fn/calc.hpp"
#include "getString.hpp"
#include "output.hpp"
#include "rounding.hpp"
#include "util.hpp"
Expand All @@ -41,6 +43,7 @@
using namespace std::literals;
using namespace steppable::__internals::arithmetic;
using namespace steppable::__internals::numUtils;
using namespace steppable::localization;
using namespace steppable::output;

namespace steppable::__internals::arithmetic
Expand Down Expand Up @@ -75,7 +78,7 @@ namespace steppable::__internals::arithmetic
// (6)
if (isZeroString(x) and isZeroString(y)) [[unlikely]]
{
error("atan2"s, "atan2 is not defined here."s);
error("atan2"s, $("atan2", "8d78a4a1-4b3e-431a-a0fc-9a0e663b3281"));
return "Undefined";
}

Expand All @@ -100,12 +103,25 @@ namespace steppable::__internals::arithmetic
if (compare(x, "0", 0) == "0" and compare(y, "0", 0) == "0") [[likely]]
return subtract(atanYOverX, static_cast<std::string>(constants::PI), 0);

// Will never be executed. Just here for Clangd.
return "Impossible! How did you get here?";
}
} // namespace steppable::__internals::arithmetic

int main(int argc, const char* argv[])
#ifndef NO_MAIN
int main(int _argc, const char* _argv[])
{
std::cout << atan2("12", "10", 5) << "\n";
return 0;
Utf8CodePage();
ProgramArgs program(_argc, _argv);
program.addPosArg('y', $("atan2", "799378d1-3edd-4f97-97d2-8662b17a1819"));
program.addPosArg('x', $("atan2", "7f146d0f-4f58-4dcd-9333-2e27d7e7dcf9"));
program.addKeywordArg("decimals", 2, $("atan2", "fc72b8b9-bc77-4d44-9e99-65e1f11150e2"));
program.parseArgs();

int decimals = program.getKeywordArgument("decimals");
const auto& yStr = program.getPosArg(0);
const auto& xStr = program.getPosArg(1);

std::cout << atan2(yStr, xStr, decimals) << '\n';
}
#endif

0 comments on commit 905d6fb

Please sign in to comment.