O'Reilly logo

Beginning Math and Physics for Game Programmers by Wendy Stahler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Math Libraries in C++

As you start programming, you'll find that it's not necessary to reinvent the wheel. Many functions have already been written a thousand times, so why rewrite them? The trigonometric functions have already been mastered, and they're out there to be used. If you're coding in C++, you can include the math.h library, which already contains function calls for sine, cosine, tangent, and their inverses.

NOTE

Whenever you want to use these function calls, make sure you include math.h at the beginning of your code by using the following line:

#include <math.h>

The sine, cosine, and tangent functions take in a double and output a double. The input, or parameter, is an angle expressed in radians, and the output is a decimal ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required