Skip to navigation

Maths (Geometry): tanHalfAngle

Name: tanHalfAngle [Show more] Type: Variable Category: Maths (Geometry) Summary: Table for hypotenuse lengths given the tangent of an angle
Context: See this variable in context in the source code References: This variable is used as follows: * GetHypotenuse uses tanHalfAngle

Given the tangent of an angle, X = tan(theta), this table contains the following at index X: tanHalfAngle,X = 2 * tan(theta / 2) The table contains lookup values for indexes 0 to 128, which correspond to theta angles of 0 to 45 degrees. This allows us to approximate the length of the hypotenuse of a triangle with angle theta, adjacent side a and opposite side b, as follows: h =~ a + b * tan(theta / 2)
.tanHalfAngle EQUB 0 FOR I%, 1, 128 EQUB INT(0.5 + 2 * 256 * TAN(ATN(I% / 128) / 2)) NEXT