Custom math functions vs. supplied Math functions?

前端 未结 5 2042
滥情空心
滥情空心 2021-01-28 14:10

I am basically making a Java program that will have to run a lot of calculations pretty quickly(each frame, aiming for at least 30 f/s). These will mostly be trigonometric and p

5条回答
  •  情话喂你
    2021-01-28 15:03

    What might be an option is caching the values. If you know you are only going to need a fixed set of values or if you can get away without perfect accuracy then this could save a lot of time. Say if you want to draw a lot of circles pre compute values of sin and cos for each degree. Then use these values when drawing. Most circles will be small enough that you can't see the difference and the small number which are very big can be done using the libraries.

    Be sure to test if this is worth it. On my 5 year old macbook I can do a million evaluations of cos a second.

提交回复
热议问题