-
Notifications
You must be signed in to change notification settings - Fork 617
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wpimath] Make Rotation2d constexpr using gcem
- Loading branch information
Showing
67 changed files
with
6,755 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/*################################################################################ | ||
## | ||
## Copyright (C) 2016-2020 Keith O'Hara | ||
## | ||
## This file is part of the GCE-Math C++ library. | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
################################################################################*/ | ||
|
||
#pragma once | ||
|
||
#include "gcem/gcem_incl/gcem_options.hpp" | ||
|
||
namespace gcem { | ||
#include "gcem/gcem_incl/quadrature/gauss_legendre_50.hpp" | ||
|
||
#include "gcem/gcem_incl/is_inf.hpp" | ||
#include "gcem/gcem_incl/is_nan.hpp" | ||
#include "gcem/gcem_incl/is_finite.hpp" | ||
|
||
#include "gcem/gcem_incl/abs.hpp" | ||
#include "gcem/gcem_incl/ceil.hpp" | ||
#include "gcem/gcem_incl/floor.hpp" | ||
#include "gcem/gcem_incl/trunc.hpp" | ||
#include "gcem/gcem_incl/is_odd.hpp" | ||
#include "gcem/gcem_incl/is_even.hpp" | ||
#include "gcem/gcem_incl/max.hpp" | ||
#include "gcem/gcem_incl/min.hpp" | ||
#include "gcem/gcem_incl/sqrt.hpp" | ||
|
||
#include "gcem/gcem_incl/signbit.hpp" | ||
#include "gcem/gcem_incl/copysign.hpp" | ||
#include "gcem/gcem_incl/neg_zero.hpp" | ||
#include "gcem/gcem_incl/sgn.hpp" | ||
|
||
#include "gcem/gcem_incl/find_exponent.hpp" | ||
#include "gcem/gcem_incl/find_fraction.hpp" | ||
#include "gcem/gcem_incl/find_whole.hpp" | ||
#include "gcem/gcem_incl/mantissa.hpp" | ||
#include "gcem/gcem_incl/round.hpp" | ||
#include "gcem/gcem_incl/fmod.hpp" | ||
|
||
#include "gcem/gcem_incl/pow_integral.hpp" | ||
#include "gcem/gcem_incl/exp.hpp" | ||
#include "gcem/gcem_incl/expm1.hpp" | ||
#include "gcem/gcem_incl/log.hpp" | ||
#include "gcem/gcem_incl/log1p.hpp" | ||
#include "gcem/gcem_incl/log2.hpp" | ||
#include "gcem/gcem_incl/pow.hpp" | ||
|
||
#include "gcem/gcem_incl/gcd.hpp" | ||
#include "gcem/gcem_incl/lcm.hpp" | ||
|
||
#include "gcem/gcem_incl/tan.hpp" | ||
#include "gcem/gcem_incl/cos.hpp" | ||
#include "gcem/gcem_incl/sin.hpp" | ||
|
||
#include "gcem/gcem_incl/atan.hpp" | ||
#include "gcem/gcem_incl/atan2.hpp" | ||
#include "gcem/gcem_incl/acos.hpp" | ||
#include "gcem/gcem_incl/asin.hpp" | ||
|
||
#include "gcem/gcem_incl/tanh.hpp" | ||
#include "gcem/gcem_incl/cosh.hpp" | ||
#include "gcem/gcem_incl/sinh.hpp" | ||
|
||
#include "gcem/gcem_incl/atanh.hpp" | ||
#include "gcem/gcem_incl/acosh.hpp" | ||
#include "gcem/gcem_incl/asinh.hpp" | ||
|
||
#include "gcem/gcem_incl/binomial_coef.hpp" | ||
#include "gcem/gcem_incl/lgamma.hpp" | ||
#include "gcem/gcem_incl/tgamma.hpp" | ||
#include "gcem/gcem_incl/factorial.hpp" | ||
#include "gcem/gcem_incl/lbeta.hpp" | ||
#include "gcem/gcem_incl/beta.hpp" | ||
#include "gcem/gcem_incl/lmgamma.hpp" | ||
#include "gcem/gcem_incl/log_binomial_coef.hpp" | ||
|
||
#include "gcem/gcem_incl/erf.hpp" | ||
#include "gcem/gcem_incl/erf_inv.hpp" | ||
#include "gcem/gcem_incl/incomplete_beta.hpp" | ||
#include "gcem/gcem_incl/incomplete_beta_inv.hpp" | ||
#include "gcem/gcem_incl/incomplete_gamma.hpp" | ||
#include "gcem/gcem_incl/incomplete_gamma_inv.hpp" | ||
} // namespace gcem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/*################################################################################ | ||
## | ||
## Copyright (C) 2016-2020 Keith O'Hara | ||
## | ||
## This file is part of the GCE-Math C++ library. | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
################################################################################*/ | ||
|
||
#ifndef _gcem_abs_HPP | ||
#define _gcem_abs_HPP | ||
|
||
/** | ||
* Compile-time absolute value function | ||
* | ||
* @param x a real-valued input. | ||
* @return the absolute value of \c x, \f$ |x| \f$. | ||
*/ | ||
|
||
template<typename T> | ||
constexpr | ||
T | ||
abs(const T x) | ||
noexcept | ||
{ | ||
return( // deal with signed-zeros | ||
x == T(0) ? \ | ||
T(0) : | ||
// else | ||
x < T(0) ? \ | ||
- x : x ); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/*################################################################################ | ||
## | ||
## Copyright (C) 2016-2020 Keith O'Hara | ||
## | ||
## This file is part of the GCE-Math C++ library. | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
################################################################################*/ | ||
|
||
/* | ||
* compile-time arccosine function | ||
*/ | ||
|
||
#ifndef _gcem_acos_HPP | ||
#define _gcem_acos_HPP | ||
|
||
namespace internal | ||
{ | ||
|
||
template<typename T> | ||
constexpr | ||
T | ||
acos_compute(const T x) | ||
noexcept | ||
{ | ||
return( // only defined on [-1,1] | ||
abs(x) > T(1) ? \ | ||
GCLIM<T>::quiet_NaN() : | ||
// indistinguishable from one or zero | ||
GCLIM<T>::epsilon() > abs(x - T(1)) ? \ | ||
T(0) : | ||
GCLIM<T>::epsilon() > abs(x) ? \ | ||
T(GCEM_HALF_PI) : | ||
// else | ||
atan( sqrt(T(1) - x*x)/x ) ); | ||
} | ||
|
||
template<typename T> | ||
constexpr | ||
T | ||
acos_check(const T x) | ||
noexcept | ||
{ | ||
return( // NaN check | ||
is_nan(x) ? \ | ||
GCLIM<T>::quiet_NaN() : | ||
// | ||
x > T(0) ? \ | ||
// if | ||
acos_compute(x) : | ||
// else | ||
T(GCEM_PI) - acos_compute(-x) ); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Compile-time arccosine function | ||
* | ||
* @param x a real-valued input, where \f$ x \in [-1,1] \f$. | ||
* @return the inverse cosine function using \f[ \text{acos}(x) = \text{atan} \left( \frac{\sqrt{1-x^2}}{x} \right) \f] | ||
*/ | ||
|
||
template<typename T> | ||
constexpr | ||
return_t<T> | ||
acos(const T x) | ||
noexcept | ||
{ | ||
return internal::acos_check( static_cast<return_t<T>>(x) ); | ||
} | ||
|
||
#endif |
Oops, something went wrong.