Jump to content
  • Advertisement
Sign in to follow this  
melkor_98

VC++ Trigonomety

This topic is 5413 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
#include <math.h>

Functions include sin, cos, tan, asin, acos, atan, and atan2... look them up in the VC++ docs.

Share this post


Link to post
Share on other sites
Actually, your first step should be the VC++ docs. They contain explanations of everything in the C and C++ runtimes (including STL), as well win32 and .NET. You can also look up things like language keywords.

Share this post


Link to post
Share on other sites
Since we are in a game forum a good piece of extra information about trigonometric function is that they take some bit of time and they are used in time critical situations. Therefore using a

float SinTbl[360];
#define SIN(x) SinTbl[x]

could save something.. THen you only have to initiate it once and save time.

Share this post


Link to post
Share on other sites
Quote:
Original post by MikaelBrandin
Since we are in a game forum a good piece of extra information about trigonometric function is that they take some bit of time and they are used in time critical situations. Therefore using a

float SinTbl[360];
#define SIN(x) SinTbl[x]

could save something.. THen you only have to initiate it once and save time.


Actually a table might be slower than the standart sin() function, because it is not cache friendly at all.

Share this post


Link to post
Share on other sites
Actually, most modern processors use lookup-tables in their hardware, so you wont gain anything but a trashed cache.
Ahh, and if you cant resist to optimize (*g*), then you should perhaps use only 256 degrees instead of 360.

Thermo/Konfusius

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!