C++-Äquivalent zu NumPy/PHP rad2deg
English
Deutsch
In order to convert radians to degrees, PHP provides the rad2deg function whereas Python’s NumPy library provides np.rad2deg.
In C++ gibt es keine Standardfunktion, um Radiant in Grad umzuwandeln.
Du kannst jedoch dieses einfache Snippet verwenden:
rad2deg.cpp
#define _USE_MATH_DEFINES
#include <cmath>
/**
* Den in Radiant angegebenen Winkel in Grad umwandeln.
*/
template<typename F>
F rad2deg(F angle) {
return angle * 180.0 / M_PI;
}Dies funktioniert für double, float usw. und gibt den Winkel in Grad zurück.
Die Formel ist ziemlich einfach:
$$\text{Degrees} = \frac{\text{Radians} \cdot 180°}{\pi}$$Check out similar posts by category:
C/C++, Mathematics
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow