Skip to content

Commit

Permalink
Removed Test of non-existent turbomath trig
Browse files Browse the repository at this point in the history
  • Loading branch information
avtoku committed Oct 9, 2024
1 parent 9e330d9 commit 1d36ffd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 40 deletions.
4 changes: 1 addition & 3 deletions lib/turbomath/turbomath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ float fsign(float y) { return (0.0f < y) - (y < 0.0f); }
// ISA standard atmosphere up to 11kft:
float alt(float press)
{
#define ISA_PRESSURE (101325.0) // Pa
#define ISA_EXPONENT (0.190326730028458)
#define ISA_SCALE_FACTOR (44318.1386038261) //m

return (1.0-pow(press/ISA_PRESSURE,ISA_EXPONENT))*ISA_SCALE_FACTOR;
}

Expand Down
3 changes: 3 additions & 0 deletions lib/turbomath/turbomath.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@

namespace turbomath
{
#define ISA_PRESSURE (101325.0) // Pa
#define ISA_EXPONENT (0.190326730028458)
#define ISA_SCALE_FACTOR (44318.1386038261) //m

float fsign(float y);

Expand Down
38 changes: 1 addition & 37 deletions test/turbotrig_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,41 +90,6 @@ turbomath::Quaternion random_quaternions[25] = {
turbomath::Quaternion(-0.177027678376, 0.214558558928, -0.992910369554, 0.592964390132),
turbomath::Quaternion(0.0979109306209, 0.121890109199, 0.126418158551, 0.242200145606)};

TEST(TurboMath, atan)
{
for (float i = -200.0; i <= 200.0; i += 0.001) {
EXPECT_NEAR(turbomath::atan(i), atan(i), 0.0001);
}
}

TEST(TurboMath, sin_cos)
{
for (float i = -200.0; i <= 200.0; i += 0.001) {
EXPECT_NEAR(turbomath::sin(i), sin(i), 0.0002);
EXPECT_NEAR(turbomath::cos(i), cos(i), 0.0002);
}
}

TEST(TurboMath, atan2)
{
for (float i = -100.0; i <= 100.0; i += 0.1) {
for (float j = -1.0; j <= 1.0; j += 0.001) {
if (fabs(j) > 0.0001) { EXPECT_NEAR(turbomath::atan2(i, j), atan2(i, j), 0.001); }
}
}
}

TEST(TurboMath, asin)
{
for (float i = -1.0; i <= 1.0; i += 0.001) {
if (fabs(i) < 0.95) {
EXPECT_NEAR(turbomath::asin(i), asin(i), 0.0001);
} else {
EXPECT_NEAR(turbomath::asin(i), asin(i), 0.2);
}
}
}

TEST(TurboMath, fastAlt)
{
// out of bounds
Expand All @@ -135,8 +100,7 @@ TEST(TurboMath, fastAlt)
float trueResult = 0.0;
for (int i = 69682; i < 106597; i++) {
trueResult =
static_cast<float>((1.0 - pow(static_cast<float>(i) / 101325, 0.190284)) * 145366.45)
* static_cast<float>(0.3048);
static_cast<float>((1.0 - pow(static_cast<float>(i) /ISA_PRESSURE, ISA_EXPONENT)) * ISA_SCALE_FACTOR);
EXPECT_NEAR(turbomath::alt(i), trueResult, .15);
// arbitrarily chose <= .15m since fast_alt isn't accurate enough for EXPECT_CLOSE,
// but being within .15 meters of the correct result seems pretty good to me
Expand Down

0 comments on commit 1d36ffd

Please sign in to comment.