sigma  0.0.0
Loading...
Searching...
No Matches
trigonometry.ipp
1#pragma once
3#include <cmath>
4
5namespace sigma {
6
7template<typename T>
9 auto to_degrees = 180.0 / detail_::pi;
10 T mean = a.mean() * to_degrees;
11 T dcda = to_degrees;
12 return detail_::unary_result(a, mean, dcda);
13}
14
15template<typename T>
17 auto to_radians = detail_::pi / 180.0;
18 T mean = a.mean() * to_radians;
19 T dcda = to_radians;
20 return detail_::unary_result(a, mean, dcda);
21}
22
23template<typename T>
25 T mean = std::sin(a.mean());
26 T dcda = std::cos(a.mean());
27 return detail_::unary_result(a, mean, dcda);
28}
29
30template<typename T>
32 T mean = std::cos(a.mean());
33 T dcda = -std::sin(a.mean());
34 return detail_::unary_result(a, mean, dcda);
35}
36
37template<typename T>
39 T mean = std::tan(a.mean());
40 T dcda = std::pow(std::tan(a.mean()), 2.0) + 1;
41 return detail_::unary_result(a, mean, dcda);
42}
43
44template<typename T>
46 T mean = std::asin(a.mean());
47 T dcda = 1 / std::sqrt(1 - std::pow(a.mean(), 2));
48 return detail_::unary_result(a, mean, dcda);
49}
50
51template<typename T>
53 T mean = std::acos(a.mean());
54 T dcda = -1 / std::sqrt(1 - std::pow(a.mean(), 2));
55 return detail_::unary_result(a, mean, dcda);
56}
57
58template<typename T>
60 T mean = std::atan(a.mean());
61 T dcda = 1 / (1 + std::pow(a.mean(), 2));
62 return detail_::unary_result(a, mean, dcda);
63}
64
65template<typename T>
67 T mean = std::atan2(y.mean(), x.mean());
68 T dcda = x.mean() / (std::pow(x.mean(), 2) + std::pow(y.mean(), 2));
69 T dcdb = -y.mean() / (std::pow(x.mean(), 2) + std::pow(y.mean(), 2));
70 return detail_::binary_result(y, x, mean, dcda, dcdb);
71}
72
73template<typename T, typename U>
74Uncertain<T> atan2(const Uncertain<T>& y, const U& x) {
75 T mean = std::atan2(y.mean(), x);
76 T dcda = x / (std::pow(x, 2) + std::pow(y.mean(), 2));
77 return detail_::unary_result(y, mean, dcda);
78}
79
80template<typename T, typename U>
81Uncertain<T> atan2(const U& y, const Uncertain<T>& x) {
82 T mean = std::atan2(y, x.mean());
83 T dcda = -y / (std::pow(x.mean(), 2) + std::pow(y, 2));
84 return detail_::unary_result(x, mean, dcda);
85}
86
87} // namespace sigma
Models an unceratin variable.
Definition uncertain.hpp:33
value_t mean() const
Get the mean value of the variable.
Definition uncertain.hpp:82
constexpr double pi
Value of Pi.
Definition operation_common.hpp:13
Uncertain< T > unary_result(const Uncertain< T > &a, T mean, T dcda)
Generalized Unary Changes.
Definition operation_common.hpp:44
Uncertain< T > binary_result(const Uncertain< T > &a, const Uncertain< T > &b, T mean, T dcda, T dcdb)
Generalized Binary Changes.
Definition operation_common.hpp:85
The primary namespace for the sigma library.
Definition operation_common.hpp:10
Uncertain< T > atan2(const Uncertain< T > &y, const Uncertain< T > &x)
Two argument arctangent.
Definition trigonometry.ipp:66
Uncertain< T > sin(const Uncertain< T > &a)
Sine of the variable.
Definition trigonometry.ipp:24
Uncertain< T > atan(const Uncertain< T > &a)
Arctangent of the variable.
Definition trigonometry.ipp:59
Uncertain< T > cos(const Uncertain< T > &a)
Cosine of the variable.
Definition trigonometry.ipp:31
Uncertain< T > tan(const Uncertain< T > &a)
Tangent of the variable.
Definition trigonometry.ipp:38
Uncertain< T > degrees(const Uncertain< T > &a)
Convert from radians to degrees.
Definition trigonometry.ipp:8
Uncertain< T > asin(const Uncertain< T > &a)
Arcsine of the variable.
Definition trigonometry.ipp:45
Uncertain< T > radians(const Uncertain< T > &a)
Convert from degrees to radians.
Definition trigonometry.ipp:16
Uncertain< T > acos(const Uncertain< T > &a)
Arccosine of the variable.
Definition trigonometry.ipp:52
Common implementation details for operations.