1

I have seen many implementations for this but I got this new idea about which I couldn't be sure. So I need an opinion here.

The idea is that instead of looking up the table for arctan(gy/gx), look for 1/gx in one table and multiply the result with gy. Then lookup for arctan. The reason for doing so is to reduce hardware cost as division is more expensive than multiplication. But the limitation is that I can have a maximum of 10 address bits. Whereas, multiplication will give me twice the number of bits in gx. gx itself is 8 bits. If I right shift gy*(1/gx) by 6 bits to get a 10 bit address,

What could be the degree of error?

Harsh Wardhan
  • 2,110
  • 10
  • 36
  • 51
  • 1
    Hint: Some values are more useful than others. Only keep the useful ones. – Ignacio Vazquez-Abrams May 10 '14 at 05:31
  • if you use 1/gx lookup table you will probably loose some precision (hope you have floating point not fixed one). also what division for FP you use? some approximation approaches are comparable with the lookup table runtime like this one http://stackoverflow.com/a/18398246/2521214 of course if you do not have fast multiplication then lookup table is better for you ... – Spektre May 10 '14 at 07:14
  • What is the range of gx and gy? In addition, how much does a multiplication cost relatively to division on your target machine? – Alex Shtoff May 11 '14 at 08:22
  • Also, are gx and gy integers? – Alex Shtoff May 11 '14 at 08:28
  • gx and gy are integers – Harsh Wardhan May 12 '14 at 05:11

1 Answers1

2

Note you only need to consider the case when gy > gx as arctan(gy/gx)=90-arctan(gx/gy) (assuming we are working in degrees in positive coordinate). This might reduce you errors with division.

Salix alba
  • 7,536
  • 2
  • 32
  • 38