17 lines
613 B
C++
17 lines
613 B
C++
#ifndef COORDINATE_CONVERSION_H
|
|
#define COORDINATE_CONVERSION_H
|
|
#include <cmath>
|
|
|
|
void polar_to_cartesian(const double RADIUS, const double ANGLE,
|
|
double* pXCoordinate, double* pYCoordinate) {
|
|
*pXCoordinate = RADIUS * std::cos(ANGLE);
|
|
*pYCoordinate = RADIUS * std::sin(ANGLE);
|
|
}
|
|
|
|
void cartesian_to_polar(const double X_COORDINATE, const double Y_COORDINATE,
|
|
double* pRadius, double* pAngle) {
|
|
*pRadius = std::sqrt(std::pow(X_COORDINATE, 2) + std::pow(Y_COORDINATE, 2));
|
|
*pAngle = std::atan(X_COORDINATE / Y_COORDINATE);
|
|
}
|
|
|
|
#endif // COORDINATE_CONVERSION_H
|