From 773e340770a384fee2e3283756e38725f19b8647 Mon Sep 17 00:00:00 2001 From: Daniel Warner Date: Sat, 24 Dec 2011 14:55:21 +0000 Subject: [PATCH] Removed unnecessary pow --- Julian.cpp | 4 +++- SGP4.cpp | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Julian.cpp b/Julian.cpp index f1177aa..b78776f 100644 --- a/Julian.cpp +++ b/Julian.cpp @@ -231,10 +231,12 @@ double Julian::ToGreenwichSiderealTime() const // (since J2000 which is 2451545.0) // a Julian century is 36525 days const double tut1 = (date_ - 2451545.0) / 36525.0; + const double tut2 = tut1 * tut1; + const double tut3 = tut2 * tut1; // Rotation angle in arcseconds double theta = 67310.54841 + (876600.0 * 3600.0 + 8640184.812866) * tut1 - + 0.093104 * pow(tut1, 2.0) - 0.0000062 * pow(tut1, 3.0); + + 0.093104 * tut2 - 0.0000062 * tut3; // 360.0 / 86400.0 = 1.0 / 240.0 theta = Util::WrapTwoPI(Util::DegreesToRadians(theta / 240.0)); diff --git a/SGP4.cpp b/SGP4.cpp index 9264401..f2edc6b 100644 --- a/SGP4.cpp +++ b/SGP4.cpp @@ -99,7 +99,7 @@ void SGP4::Initialise() common_consts_.x3thm1 * (8.0 + 3.0 * etasq * (8.0 + etasq))); common_consts_.c1 = elements_.BStar() * c2; - common_consts_.a3ovk2 = -kXJ3 / kCK2 * pow(kAE, 3.0); + common_consts_.a3ovk2 = -kXJ3 / kCK2 * kAE * kAE * kAE; common_consts_.x1mth2 = 1.0 - theta2; common_consts_.c4 = 2.0 * elements_.RecoveredMeanMotion() * coef1 * elements_.RecoveredSemiMajorAxis() * betao2 * (common_consts_.eta * (2.0 + 0.5 * etasq) + elements_.Eccentricity() * (0.5 + 2.0 * etasq) - @@ -239,7 +239,7 @@ Eci SGP4::FindPositionSDP4(double tsince) const throw SatelliteException("Error: #2 (xn <= 0.0)"); } - a = pow(kXKE / xn, kTWOTHIRD) * pow(tempa, 2.0); + a = pow(kXKE / xn, kTWOTHIRD) * tempa * tempa; e -= tempe; double xmam = xmdf + elements_.RecoveredMeanMotion() * templ; @@ -360,7 +360,7 @@ Eci SGP4::FindPositionSGP4(double tsince) const templ += nearspace_consts_.t3cof * tcube + tfour * (nearspace_consts_.t4cof + tsince * nearspace_consts_.t5cof); } - a = elements_.RecoveredSemiMajorAxis() * pow(tempa, 2.0); + a = elements_.RecoveredSemiMajorAxis() * tempa * tempa; e = elements_.Eccentricity() - tempe; xl = xmp + omega + xnode + elements_.RecoveredMeanMotion() * templ;