MATH: Remove duplicated deg/rad-conversions, replacing them by common/math.h-functionality
This commit is contained in:
parent
5c4100d353
commit
adc0067bf7
3 changed files with 9 additions and 15 deletions
|
@ -20,6 +20,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "common/math.h"
|
||||||
|
|
||||||
#include "engines/myst3/scene.h"
|
#include "engines/myst3/scene.h"
|
||||||
#include "engines/myst3/node.h"
|
#include "engines/myst3/node.h"
|
||||||
#include "engines/myst3/myst3.h"
|
#include "engines/myst3/myst3.h"
|
||||||
|
@ -111,8 +113,8 @@ void Scene::drawSunspotFlare(const SunSpot &s) {
|
||||||
static Math::Vector3d directionToVector(float pitch, float heading) {
|
static Math::Vector3d directionToVector(float pitch, float heading) {
|
||||||
Math::Vector3d v;
|
Math::Vector3d v;
|
||||||
|
|
||||||
float radHeading = Math::degreeToRadian(heading);
|
float radHeading = Common::deg2rad(heading);
|
||||||
float radPitch = Math::degreeToRadian(pitch);
|
float radPitch = Common::deg2rad(pitch);
|
||||||
|
|
||||||
v.setValue(0, cos(radPitch) * cos(radHeading));
|
v.setValue(0, cos(radPitch) * cos(radHeading));
|
||||||
v.setValue(1, sin(radPitch));
|
v.setValue(1, sin(radPitch));
|
||||||
|
|
|
@ -21,9 +21,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common/streamdebug.h"
|
#include "common/streamdebug.h"
|
||||||
|
#include "common/math.h"
|
||||||
|
|
||||||
#include "math/angle.h"
|
#include "math/angle.h"
|
||||||
#include "math/utils.h"
|
|
||||||
|
|
||||||
namespace Math {
|
namespace Math {
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ void Angle::setDegrees(float degrees) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Angle::setRadians(float radians) {
|
void Angle::setRadians(float radians) {
|
||||||
_degrees = radianToDegree(radians);
|
_degrees = Common::rad2deg(radians);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Angle::getDegrees() const {
|
float Angle::getDegrees() const {
|
||||||
|
@ -65,7 +65,7 @@ float Angle::getDegrees() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
float Angle::getRadians() const {
|
float Angle::getRadians() const {
|
||||||
return degreeToRadian(getDegrees());
|
return Common::deg2rad(getDegrees());
|
||||||
}
|
}
|
||||||
|
|
||||||
float Angle::getDegrees(float low) const {
|
float Angle::getDegrees(float low) const {
|
||||||
|
@ -82,7 +82,7 @@ float Angle::getDegrees(float low) const {
|
||||||
|
|
||||||
float Angle::getRadians(float low) const {
|
float Angle::getRadians(float low) const {
|
||||||
float d = getDegrees(low);
|
float d = getDegrees(low);
|
||||||
return degreeToRadian(d);
|
return Common::deg2rad(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Angle::getCosine() const {
|
float Angle::getCosine() const {
|
||||||
|
@ -134,7 +134,7 @@ Angle &Angle::operator-=(float degrees) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Angle Angle::fromRadians(float radians) {
|
Angle Angle::fromRadians(float radians) {
|
||||||
return Angle(radianToDegree(radians));
|
return Angle(Common::rad2deg(radians));
|
||||||
}
|
}
|
||||||
|
|
||||||
Angle Angle::arcCosine(float x) {
|
Angle Angle::arcCosine(float x) {
|
||||||
|
|
|
@ -27,14 +27,6 @@
|
||||||
|
|
||||||
namespace Math {
|
namespace Math {
|
||||||
|
|
||||||
inline float radianToDegree(float rad) {
|
|
||||||
return rad * 180.f / LOCAL_PI;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline float degreeToRadian(float degree) {
|
|
||||||
return degree * LOCAL_PI / 180.f;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline float square(float x) {
|
inline float square(float x) {
|
||||||
return x * x;
|
return x * x;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue