Cheap algorithm to find measure of angle between vectors

前端 未结 9 1607
旧时难觅i
旧时难觅i 2020-12-13 01:02

Finding the angle between two vectors is not hard using the cosine rule. However, because I am programming for a platform with very limited resources, I would like to avoid

9条回答
  •  孤城傲影
    2020-12-13 01:06

    Back in the day of a few K of RAM and machines with limited mathematical capabilities I used lookup tables and linear interpolation. The basic idea is simple: create an array with as much resolution as you need (more elements reduce the error created by interpolation). Then interpolate between lookup values.

    Here is an example in processing (original dead link).

    You can do this with your other trig functions as well. On the 6502 processor this allowed for full 3D wire frame graphics to be computed with an order of magnitude speed increase.

提交回复
热议问题