Skip to content
Snippets Groups Projects
Commit 95b421fc authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

[ADD] radians <-> degree conversion functions

parent 3273c128
Branches
No related merge requests found
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
#pragma once
#include "Constants.h"
namespace walberla
{
namespace math
{
///Converts a degrees angle to radians.
constexpr real_t degToRad(real_t deg) {return deg * (pi / real_t(180));}
///Converts a radians angle to degrees.
constexpr real_t radToDeg(real_t rad) {return rad * (real_t(180) / pi);}
} // namespace math
} // namespace walberla
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
#include "core/DataTypes.h"
#include "core/math/Angles.h"
#include "core/debug/TestSubsystem.h"
namespace walberla{
int main( int /*argc*/, char** /*argv*/ )
{
using namespace walberla::math;
debug::enterTestMode();
WALBERLA_CHECK_FLOAT_EQUAL( radToDeg(half_pi), 90_r );
WALBERLA_CHECK_FLOAT_EQUAL( half_pi, degToRad(90_r) );
return EXIT_SUCCESS;
}
} //namespace walberla
int main( int argc, char** argv )
{
return walberla::main(argc, argv);
}
...@@ -186,6 +186,9 @@ else() ...@@ -186,6 +186,9 @@ else()
endif() endif()
waLBerla_execute_test( NAME AllHeaderTest ) waLBerla_execute_test( NAME AllHeaderTest )
waLBerla_compile_test( FILES Angles.test.cpp )
waLBerla_execute_test( NAME Angles )
waLBerla_compile_test( FILES ConcatIterator.cpp ) waLBerla_compile_test( FILES ConcatIterator.cpp )
waLBerla_execute_test( NAME ConcatIterator ) waLBerla_execute_test( NAME ConcatIterator )
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment