Trig lookup tables
What is the best way to create trig lookup tables? For the basic sin, cos and tan functions it would be easy, but what about inverse sin, cos and tan. These take inputs from 0...1, except for inverse tan, which takes inputs from 0 to infinity! What is the best(ei. fastest and least messy) way to create lookup tables for those? Thanks.
November 21, 2000 07:02 PM
Lookup tables for the inverse trigonometric functions are very similar. One way that it can be done is to scale the array index by a power of ten. For example, if you are looking up values in the range of 0 to 1, you obviously couldn''t do this:
angle = arcsin[0.236];
however, you could do the following:
angle = acrsin[236];
If you create arrays of sizes of powers of 10 (100, 1000 etc) then you can simply shift the decimal point to look it up.
A disadvantage of this technique however is that it requires large amounts of memory to get a decent amount of decimal accuracey. For example, in the example above, you would need need to create arrays with some 1000 entries.
As for inverse of tangent, this simply is not necessary. All you really need are look up tables for arcsin and arccos. You can pretty much figure out all the other trigonometric functions with just these 2. For example, say you needed to find arctan(a). One way to evaluate this using the sin and cos inverse functions is as follows:
arccos( 1/sqrt(a*a + 1) );
The method above works well, however it does require a square root.
Here are some trigonometric identities to remember:
tan(a) = sin(a)/cos(a)
sec(a) = 1/cos(a)
cot(a) = a/tan(a) = cos(a)/sin(a)
csc(a) = a/sin(a)
sin^2(a) + cos^2(a) = 1
1+tan^2(a) = sec^2(a)
1+cot^2(a) = csc^2(a)
angle = arcsin[0.236];
however, you could do the following:
angle = acrsin[236];
If you create arrays of sizes of powers of 10 (100, 1000 etc) then you can simply shift the decimal point to look it up.
A disadvantage of this technique however is that it requires large amounts of memory to get a decent amount of decimal accuracey. For example, in the example above, you would need need to create arrays with some 1000 entries.
As for inverse of tangent, this simply is not necessary. All you really need are look up tables for arcsin and arccos. You can pretty much figure out all the other trigonometric functions with just these 2. For example, say you needed to find arctan(a). One way to evaluate this using the sin and cos inverse functions is as follows:
arccos( 1/sqrt(a*a + 1) );
The method above works well, however it does require a square root.
Here are some trigonometric identities to remember:
tan(a) = sin(a)/cos(a)
sec(a) = 1/cos(a)
cot(a) = a/tan(a) = cos(a)/sin(a)
csc(a) = a/sin(a)
sin^2(a) + cos^2(a) = 1
1+tan^2(a) = sec^2(a)
1+cot^2(a) = csc^2(a)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement