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 ...

Get Beginning Math and Physics for Game Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.