Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::vector<long double> Cordic::Iterate(std::vector<long double>& nextIteration, int currentIteration)
- {
- ///////////////////////////////////////
- // Implement the rotation equations. //
- ///////////////////////////////////////
- // 'nextIteration[0]' item : x_{x+1} = x_i - d_{i}*y_{i}*2^{-i}
- // 'nextIteration[1]' item : y_{y+1} = y_i + d_{i}*x_{i}*2^{-i}
- // 'nextIteration[2]' item : z_{i+1} = z_i - d_{i}*\alpha_i
- // All units are in radians.
- nextIteration[0] = nextIteration[0] - Utility::Sgn(nextIteration[2]) * nextIteration[1] * exp2(-currentIteration);
- nextIteration[1] = nextIteration[1] + Utility::Sgn(nextIteration[2]) * nextIteration[0] * exp2(-currentIteration);
- nextIteration[2] = nextIteration[2] - Utility::Sgn(nextIteration[2]) * this->ArctanLookupTable[currentIteration];
- currentIteration++;
- //std::cout << currentIteration;
- if (currentIteration == Utility::ITERATION_MAX)
- {
- return nextIteration;
- }
- else
- {
- nextIteration = Iterate(nextIteration, currentIteration);
- return nextIteration;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement