Skip to content
Snippets Groups Projects
Commit cefe46bd authored by Andre Offringa's avatar Andre Offringa
Browse files

Merge branch '4-fix-constants-h' into 'master'

Deprecated custom defined constants in favor of cmath definitions

Closes #4

See merge request !13
parents 05c8429b 491712b1
No related branches found
No related tags found
1 merge request!13Deprecated custom defined constants in favor of cmath definitions
Pipeline #1846 passed
#include "BeamFormer.h"
#include "MathUtil.h"
#include "Constants.h"
#include <cmath>
constexpr double speed_of_light = 299792458.0;
namespace LOFAR {
namespace StationResponse {
......@@ -49,7 +49,7 @@ std::vector<std::complex<double>> BeamFormer::compute_geometric_response(double
direction[1] * (antenna->m_phase_reference_position[1] - m_local_phase_reference_position[1]) +
direction[2] * (antenna->m_phase_reference_position[2] - m_local_phase_reference_position[2]);
double phase = -2 * M_PI * dl / (speed_of_light / freq);
double phase = -2 * M_PI * dl / (Constants::c / freq);
result.push_back({std::sin(phase), std::cos(phase)});
}
return result;
......
......@@ -35,15 +35,6 @@ namespace StationResponse
/** %Constants used in this library. */
namespace Constants
{
/** 2.0 * pi */
const real_t _2pi = 6.283185307179586476925286;
/** pi / 2.0 */
const real_t pi_2 = 1.570796326794896619231322;
/** pi / 4.0 */
const real_t pi_4 = 0.7853981633974483096156608;
/** Speed of light (m/s) */
const real_t c = 2.99792458e+08;
} //# namespace Constants
......
......@@ -26,7 +26,6 @@
// \file
// Various mathematical operations on vectors and matrices.
#include "Constants.h"
#include "Types.h"
namespace LOFAR {
......@@ -57,7 +56,7 @@ inline vector3r_t normalize(const vector3r_t &arg0)
inline vector2r_t cart2thetaphi(const vector3r_t &cart)
{
real_t r = sqrt(cart[0] * cart[0] + cart[1] * cart[1]);
vector2r_t thetaphi = {{Constants::pi_2 - atan2(cart[2], r), atan2(cart[1],
vector2r_t thetaphi = {{M_PI_2 - atan2(cart[2], r), atan2(cart[1],
cart[0])}};
return thetaphi;
}
......
......@@ -13,8 +13,6 @@
namespace LOFAR {
namespace StationResponse {
// PI / 2.0
const double pi_2 = 1.570796326794896619231322;
std::shared_ptr<HamakerElementResponse> HamakerElementResponse::getInstance(const std::string &name)
{
......@@ -48,9 +46,9 @@ void HamakerElementResponse::response(
response[0][1] = 0.0;
response[1][0] = 0.0;
response[1][1] = 0.0;
// Clip directions below the horizon.
if(theta >= pi_2)
if(theta >= M_PI_2)
{
return;
}
......
......@@ -29,9 +29,6 @@
// them invisible outside this translation unit.
namespace
{
// PI / 2.0
const double pi_2 = 1.570796326794896619231322;
#include "DefaultCoeffLBA.cc"
#include "DefaultCoeffHBA.cc"
}
......@@ -65,7 +62,7 @@ void element_response(double freq, double theta, double phi,
response[1][1] = 0.0;
// Clip directions below the horizon.
if(theta >= pi_2)
if(theta >= M_PI_2)
{
return;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment