like this. everything is mono spaced and nothing disapears on you.
use the code tags to display your examples.
ok, but what about when you are using fractions and such and you want precision? i want to make a lookup table for sines of distances to a point. the distance function will frequently return a fraction. so how would i create a lookup table for fractions (e.g. sin(.88624132))?
_________________Gecko___
_________________Gecko___
_________________Gecko___Gecko Design
In practice you wouldn''t create a lookup that would match .88624132 exactly. You''d have a lookup for .886 or .8862 maybe. Then when you''d want to index .886 you''d multiply the .886 by say a 1000 to get 886. And use the 886 to index your lookup table. How closely you want to match your fractions depends on how large you want your lookup-tables. The alternative would be to use a hash-table that accepted floating point arguments.
If you want a little more precision at the cost
of a little speed, consider interpolating your
answer from the two closest lookup in the table.
For example, if you have a result that is 1.4 and
your lookup only shows answers for 1 and 2, your
result should be
lookup[1] + ((lookup[2] - lookup[1]) * 0.4)
This assumes that your functions is a "continuous"
function, but sine and cosine are.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement