   How slow are acos()/asin()
  I think I may be forced into using these maybe up to a few hundred times per frame in my game. I know they are pretty slow but is this usage significant or only when doing 10s of thousands of them? What''s the comparitive performance with sqrt()? Using MSVC++ but I guess it''s the ASM ops that matter. 
  You usually see people making an array of pre-calculated values for sin/cos/etc.  That way you can just do:myAngle = cosArray[45];or something.  This is a lot faster than actually calling the function.  However this only works if your array has enough values to satisfy your situation.I''ve used arrays as big as 90 with very good results (1 for each 4 degrees). ;  Profile.Generally, though, they''re pretty slow. 100+ invocations per frame can have a significant hit depending on platform. Profile first, and if there seems to be a bottleneck, consider using a lookup table. ;  They can be slow.  First implement it with the calls.  Once it works look into optimizing it with lookup tables.  For all you know your bottleneck may be elsewhere.   Get it working, profile, then optimize.Edit: Doh!  #3 beat me to it :-)   [edited by - mauman on February 12, 2004 1:32:02 PM];  make namespace doohg {    double cos(double);    double sin(double);}and you can call doohg::cos etc.doohg::cos should call ::costhen you can easily replace it later if you wish ;  You can make acos and asin much faster by using  #pragma intrinsic (asin)#pragma intrinsic (acos)at the beginning of your code.When you make them intrinsic, the calls to acos and asin are passed directly to the floating-point chip, and bypass the overhead of function calls. ;  Yeah, so what's the deal with the function calls? It often gets talked about that simple sin() calls get loads of crap put in them but MS wouldn't make it slow needlessly (unless it's purely the overhead to call the function?)IIRC, acos and asin are defined only in [-1,1] which makes the range of a lookup table good (especially since symmetry can be exploited to halve the size). But they are not 1-1 functions even over a range of pi unless you force theta to be in [-pi/2,pi/2] for asin and [0,pi] for acos. The main thing I want this for is to get the rotation angle about the rotation axis from a quaternion See Qs 56 & 57, is this restricted domain good enough?   Oh and I assume when you talk about fairly small lookup tables you'd want to use at least linear & maybe quadratic interpolation?   [edited by - d000hg on February 13, 2004 4:00:00 AM];  I doubt that using acos/asin a few hundred times per frame will have any noticable impact on your frame rate. When you are rendering in 3D, directx/opengl will be using these functions a lot (e.g. when doing the lighting, it needs to know the angle between the normal to the surface and the light source which involves taking the acos of the dot product of the two vectors). So it can''t be that bad... ;  Why exactly does OpenGL need to know the angle? Lambert shading (the model it uses in general) requires only the cos of the angle between the two vectors.... precisely what you get for two unit vectors. asin/acos are not really used. If you have to use them in your code however... as people have said... use them, then if you find that they are a performance bottleneck... think about optimizing then (and only then). Never assume things will need optimizing and do it too early. Very often I have assumed something will be a bottleneck, and the real problem was somewhere else altogether. A good profiler (AQtime is v nice... gprof is pretty good too) is your friend. ;  just wondering what you are using it for and also whether the value you are calculating is the same each time 