Angle pt 2 – Side Opposite; Side Adjacent

When you have two sides of a right triangle, calculating the tangent of the half angle is straightforward. Calculate the square root of the sum of the squares of the side opposite, y, and the side adjacent, x (r in the equation below). When x is negative, use the ratio of -y to r-x and set the pi bit; otherwise, use the ratio of y to r+x and clear the pi bit. Note that the ratio is always between -1.0 and 1.0.
prev continue