Expand the sin/cos tables to 4096

The pistol grip controller has encoders with more counts.

Change-Id: I8bad6c7c2c5b1ba33bd576a3fd71cbd610568917
diff --git a/motors/math.h b/motors/math.h
index 851a90a..fce3a56 100644
--- a/motors/math.h
+++ b/motors/math.h
@@ -23,7 +23,7 @@
 
 namespace math_internal {
 
-constexpr uint32_t SinCosTableSize() { return 1024; }
+constexpr uint32_t SinCosTableSize() { return 4096; }
 
 constexpr float FloatMaxMagnitude() { return 1.0f; }
 
@@ -70,9 +70,10 @@
 }
 
 inline float FastTableLookupFloat(float theta, const float *table) {
-  const int index = (SinCosTableSize() / 2) +
-                    static_cast<int32_t>(theta * ((SinCosTableSize() / 2) /
-                                                  FloatMaxMagnitude()));
+  static constexpr float kScalar =
+      (SinCosTableSize() / 2) / FloatMaxMagnitude();
+  const int index =
+      (SinCosTableSize() / 2) + static_cast<int32_t>(theta * kScalar);
   return table[index];
 }
 
diff --git a/motors/math_test.cc b/motors/math_test.cc
index 672ee69..1c7708e 100644
--- a/motors/math_test.cc
+++ b/motors/math_test.cc
@@ -41,12 +41,14 @@
   CheckSinCos<::std::ratio<1, 8>>();
   CheckSinCos<::std::ratio<1, 128>>();
   CheckSinCos<::std::ratio<1, 1024>>();
+  CheckSinCos<::std::ratio<1, 4096>>();
 }
 
 TEST_F(SinCosIntTest, Numerator5) {
   CheckSinCos<::std::ratio<5, 8>>();
   CheckSinCos<::std::ratio<5, 128>>();
   CheckSinCos<::std::ratio<5, 1024>>();
+  CheckSinCos<::std::ratio<5, 4096>>();
 }
 
 class SinCosFloatTest : public ::testing::Test {