Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. std::vector<long double> Cordic::Iterate(std::vector<long double>& nextIteration, int currentIteration)
  2. {
  3.     ///////////////////////////////////////
  4.     // Implement the rotation equations. //
  5.     ///////////////////////////////////////
  6.     // 'nextIteration[0]' item : x_{x+1} = x_i - d_{i}*y_{i}*2^{-i}
  7.     // 'nextIteration[1]' item : y_{y+1} = y_i + d_{i}*x_{i}*2^{-i}
  8.     // 'nextIteration[2]' item : z_{i+1} = z_i - d_{i}*\alpha_i
  9.     // All units are in radians.
  10.  
  11.     nextIteration[0] = nextIteration[0] - Utility::Sgn(nextIteration[2]) * nextIteration[1] * exp2(-currentIteration);
  12.     nextIteration[1] = nextIteration[1] + Utility::Sgn(nextIteration[2]) * nextIteration[0] * exp2(-currentIteration);
  13.     nextIteration[2] = nextIteration[2] - Utility::Sgn(nextIteration[2]) * this->ArctanLookupTable[currentIteration];
  14.  
  15.     currentIteration++;
  16.     //std::cout << currentIteration;
  17.     if (currentIteration == Utility::ITERATION_MAX)
  18.     {
  19.         return nextIteration;
  20.     }
  21.     else
  22.     {
  23.         nextIteration = Iterate(nextIteration, currentIteration);
  24.         return nextIteration;
  25.     }      
  26.    
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement