This commit is contained in:
Tyler Beckman 2024-09-20 19:40:46 -06:00
parent 23003e0d34
commit 4fdd776448
Signed by: Ty
GPG key ID: 2813440C772555A4
2 changed files with 18 additions and 18 deletions

View file

@ -2,16 +2,16 @@
#define COORDINATE_CONVERSION_H #define COORDINATE_CONVERSION_H
#include <cmath> #include <cmath>
void polar_to_cartesian(double radius, double angle, double *xCoordinate, void polar_to_cartesian(const double RADIUS, const double ANGLE, double *pXCoordinate,
double *yCoordinate) { double *pYCoordinate) {
*xCoordinate = radius * std::cos(angle); *pXCoordinate = RADIUS * std::cos(ANGLE);
*yCoordinate = radius * std::sin(angle); *pYCoordinate = RADIUS * std::sin(ANGLE);
} }
void cartesian_to_polar(double xCoordinate, double yCoordinate, double *radius, void cartesian_to_polar(const double X_COORDINATE, const double Y_COORDINATE, double *pRadius,
double *angle) { double *pAngle) {
*radius = std::sqrt(std::pow(xCoordinate, 2) + std::pow(yCoordinate, 2)); *pRadius = std::sqrt(std::pow(X_COORDINATE, 2) + std::pow(Y_COORDINATE, 2));
*angle = std::atan(xCoordinate / yCoordinate); *pAngle = std::atan(X_COORDINATE / Y_COORDINATE);
} }
#endif // COORDINATE_CONVERSION_H #endif // COORDINATE_CONVERSION_H

View file

@ -5,22 +5,22 @@
* @brief Converts passed polar coordinates to their cartesian equivalent, using * @brief Converts passed polar coordinates to their cartesian equivalent, using
* pass-by-pointer * pass-by-pointer
* *
* @param radius The radius of the polar coordinates * @param RADIUS The radius of the polar coordinates
* @param angle The angle of the polar coordinates * @param ANGLE The angle of the polar coordinates
* @param xCoordinate A pointer referencing the variable to place the x component of the cartesian coordinates into * @param pXCoordinate A pointer referencing the variable to place the x component of the cartesian coordinates into
* @param yCoordinate A pointer referencing the variable to place the y component of the cartesian coordinates into * @param pYCoordinate A pointer referencing the variable to place the y component of the cartesian coordinates into
*/ */
void polar_to_cartesian(double radius, double angle, double* xCoordinate, double* yCoordinate); void polar_to_cartesian(const double RADIUS, const double ANGLE, double* pXCoordinate, double* pYCoordinate);
/** /**
* @brief Converts passed cartesian coordinates to their polar equivalent, using * @brief Converts passed cartesian coordinates to their polar equivalent, using
* pass-by-pointer * pass-by-pointer
* *
* @param x The x component of the cartesian coordinates * @param X_COORDINATE The x component of the cartesian coordinates
* @param y The y component of the cartesian coordinates * @param Y_COORDINATE The y component of the cartesian coordinates
* @param radius A pointer referencing the variable to put the radius of the polar coordinates into * @param pRadius A pointer referencing the variable to put the radius of the polar coordinates into
* @param angle A pointer referencing the variable to put the angle of the polar coordinates into * @param pAngle A pointer referencing the variable to put the angle of the polar coordinates into
*/ */
void cartesian_to_polar(double xCoordinate, double yCoordinate, double* radius, double* angle); void cartesian_to_polar(const double X_COORDINATE, const double Y_COORDINATE, double* pRadius, double* pAngle);
#endif // COORDINATE_CONVERSION_H #endif // COORDINATE_CONVERSION_H