Fast transcendent / trigonometric functions for Java

前端 未结 12 1850
面向向阳花
面向向阳花 2020-11-29 02:06

Since the trigonometric functions in java.lang.Math are quite slow: is there a library that does a quick and good approximation? It seems possible to do a calculation severa

12条回答
  •  悲&欢浪女
    2020-11-29 02:44

    You could pre-store your sin and cos in an array if you only need some approximate values. For example, if you want to store the values from 0° to 360°:

    double sin[]=new double[360];
    for(int i=0;i< sin.length;++i) sin[i]=Math.sin(i/180.0*Math.PI):
    

    you then use this array using degrees/integers instead of radians/double.

提交回复
热议问题