MEPP2 Project
AngleOperations.hpp
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as
6 // published by the Free Software Foundation; either version 3 of
7 // the License, or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 #pragma once
12 
13 #include "FEVV/Tools/Math/degree_rad_conversion.h" // rad2deg()
14 #include <cmath> // M_PI, asin
15 
16 
17 namespace FEVV {
18 namespace Operators {
19 
20 namespace Geometry {
21 
29 template< class T >
30 static T
31 asin(T sine)
32 {
33  if(sine >= 1.f)
34  return M_PI * 0.5f;
35  else if(sine <= -1.f)
36  return -M_PI * 0.5f;
37  else
38  return std::asin(sine);
39 }
40 
48 template< class T >
49 static T
50 asin_degree(T sine)
51 {
52  return Math::rad2deg(Geometry::asin< T >(sine));
53 }
54 
62 template< class T >
63 inline T
64 acos(T cosine)
65 {
66  if(cosine < -1.f)
67  cosine = -1.f;
68  else if(cosine > 1.f)
69  cosine = 1.f;
70 
71  return std::acos(cosine);
72 }
73 
81 template< class T >
82 inline T
83 acos_degree(T cosine)
84 {
85  return Math::rad2deg(Geometry::acos< T >(cosine));
86 }
87 } // namespace Geometry
88 
89 } // namespace Operators
90 } // namespace FEVV
degree_rad_conversion.h
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::Operators::Geometry::acos_degree
T acos_degree(T cosine)
Safe call to the std::acos function.
Definition: AngleOperations.hpp:83
FEVV::Operators::Geometry::acos
T acos(T cosine)
Safe call to the std::acos function.
Definition: AngleOperations.hpp:64
FEVV::Math::rad2deg
T rad2deg(T rad)
Definition: degree_rad_conversion.h:26
FEVV::Operators::Geometry::asin_degree
static T asin_degree(T sine)
Safe call to the std::asin function.
Definition: AngleOperations.hpp:50
FEVV::Operators::Geometry::asin
static T asin(T sine)
Safe call to the std::asin function.
Definition: AngleOperations.hpp:31