摘要 |
A method of calculating an arctangent includes coding a sign for a y-value an x-value into a 3-bit index. When the absolute value of the x-value is greater than the absolute value of the y-value, the absolute values of the x-value and the y-value are swapped, and a swap bit of the index is coded to indicate that the x-value and the y-value were swapped. The arctangent is calculated from the quotient of the swapped x-value divided by the swapped y-value. A segment base angle is extracted from a table, based on the coded x-bit, y-bit, and swap bit of the index. An encoded sign is extracted from the segment base angle and is applied to the calculated arctangent output value to define a corrected arctangent value. The segment base angle is added to the corrected arctangent value to define the arctangent of the point. |
主权项 |
1. A method of calculating an arctangent for a point located on a plane by a y-value and an x-value of a Cartesian coordinate system, the method comprising:
coding a y-bit of an index, with a controller, to indicate a sign of the y-value; coding an x-bit of the index, with the controller, to indicate a sign of the x-value; clearing a sign bit of a binary value representing the y-value, with the controller, to define a cleared y-value; clearing a sign bit of a binary value representing the x-value, with the controller, to define a cleared x-value; calculating the arctangent of the quotient of the cleared x-value divided by the cleared y-value, with the controller, to define a calculated arctangent output value, when the cleared x-value is equal to or less than the cleared y-value; swapping the cleared x-value for the cleared y-value, with the controller, to define a swapped x-value, and swapping the cleared y-value for the cleared x-value, with the controller, to define a swapped y-value, when the cleared x-value is greater than the cleared y-value; coding a swap bit of the index, with the controller, to indicate that the cleared x-value and the cleared y-value were swapped to define the swapped x-value and the swapped y-value respectively; calculating the arctangent of the quotient of the swapped x-value divided by the swapped y-value, with the controller, to define a calculated arctangent output value, when the cleared x-value is greater than the cleared y-value; looking up a segment base angle from an angle adjustment table, with the controller, based on the coded x-bit, the coded y-bit, and the coded swap bit of the index; extracting a numerical sign from a reverse bit coded into the extracted segment base angle, with the controller; applying the numerical sign of the reverse bit from the segment base angle to the calculated arctangent output value, with the controller, to define a corrected arctangent value; clearing the reverse bit of the segment base angle, with the controller, to define a cleared segment base angle; and adding the corrected arctangent value to the cleared segment base angle, with the controller, to define the arctangent of the point. |