9 template<
class Real>
class Interp_;
23 int size()
const {
return _size; }
34 typedef vector<Real> List;
36 Real linear(
const List& list,
Real idx)
const {
int cur = idx;
return Interp::linear(idx-cur, list[cur], list[(cur+1)%_size]); }
45 extern template class SinTable<Float>;
46 extern template class SinTable<Double>;
47 extern template class SinTable<Quad>;
59 static void enableSinTable(
bool enable,
int size = -1);
62 static Real sin(
Real x) {
auto& t = inst();
return t._tableEnable ? t._table.sin(x) : Real_::sin(x); }
64 static Real asin(
Real x) {
auto& t = inst();
return t._tableEnable ? t._table.asin(x) : Real_::asin(x); }
67 static Real cos(
Real x) {
auto& t = inst();
return t._tableEnable ? t._table.cos(x) : Real_::cos(x); }
69 static Real acos(
Real x) {
auto& t = inst();
return t._tableEnable ? t._table.acos(x) : Real_::acos(x); }
72 static Real tan(
Real x) {
auto& t = inst();
return t._tableEnable ? t._table.tan(x) : Real_::tan(x); }
74 static Real atan(
Real x) {
auto& t = inst();
return t._tableEnable ? t._table.atan(x) : Real_::atan(x); }
76 static Real atan2(
Real y,
Real x) {
auto& t = inst();
return t._tableEnable ? t._table.atan2(y,x) : Real_::atan2(y,x); }
91 Trig_() : _tableEnable(false) {}
96 SinTable<Real> _table;
99 static const int tableSizeDefault = 1 << 13;
Trig_< Float > Trig_f
Definition: Trig.h:103
static Real alignAngle(Real angleFrom, Real angleTo)
Calc smallest angle to align angleFrom with angleTo. Angles must be normalized. Result is in range [-...
Definition: Trig.h:86
Algebra.
Definition: Alge.h:13
Real acos(Real x) const
Definition: Trig.h:28
Real atan(Real x) const
Definition: Trig.h:30
static Real sin(Real x)
Sin of radian angle.
Definition: Trig.h:62
Speeds up all trig functions at the cost of precision. Precision is roughly 1 / size.
Definition: Trig.h:13
Interpolation math.
Definition: Quat.h:10
static Real tan(Real x)
Tan of radian angle.
Definition: Trig.h:72
int size() const
Definition: Trig.h:23
Trig_< Double > Trig_d
Definition: Trig.h:104
Alge_< Real > Alge
Definition: Alge.h:130
static Real sqrt(Real x)
Square Root.
Definition: Alge.h:63
static Real atan(Real x)
Convert tangent ratio [-inf, inf] to radian angle [-pi/2, pi/2].
Definition: Trig.h:74
static Real distanceAngle(Real angle, Real angle2)
Calc shortest angular distance between angle and angle2. Angles must be normalized. Result is in range [0, pi].
Definition: Trig.h:88
Real asin(Real x) const
Definition: Trig.cpp:41
static Real cos(Real x)
Cos of radian angle.
Definition: Trig.h:67
Real sin(Real x) const
Definition: Trig.cpp:28
static Int abs(Int x)
Get absolute value of signed integer.
Definition: Alge.h:21
static Real degree(Real radian)
Convert angle in radians to angle in degrees.
Definition: Trig.h:81
Trig_< Real > Trig
Definition: Trig.h:102
float Real
Real number type. See Real_ for real number operations and constants.
Definition: Real.h:21
Numeric type information, use numeral() to get instance safely from a static context.
Definition: Numeral.h:17
Real atan2(Real y, Real x) const
Definition: Trig.cpp:49
void resize(int size)
Definition: Trig.cpp:10
Numeral< Real >::Real_ Real_
Operations and constants for Real type. See Float_, Double_.
Definition: Real.h:25
Real tan(Real x) const
Definition: Trig.h:29
static T linear(Real t, const T &a, const T &b)
Linear interpolation. t range is [0,1].
Definition: Interp.h:28
static Real modDistSigned(Real mod, Real x, Real y)
Calc smallest signed distance between two normalized values in a modular field.
Definition: Alge.h:53
int size(const StdContainer &cont)
Safely get the size of a std container as a signed integer.
Definition: StdUtil.h:19
static Real radian(Real degree)
Convert angle in degrees to angle in radians.
Definition: Trig.h:79
static Real asin(Real x)
Convert sine ratio [-1, 1] to radian angle [-pi/2, pi/2].
Definition: Trig.h:64
static Real normalizeAngle(Real angle)
Get an equivalent angle in the normalized range [-pi, pi].
Definition: Trig.h:84
Real cos(Real x) const
Definition: Trig.h:27
Trig_< Quad > Trig_q
Definition: Trig.h:105
static Real modNormalize(Real mod, Real val)
Get an equivalent value in the normalized modular interval [-mod, mod].
Definition: Alge.h:47
SinTable()
Definition: Trig.h:20
Global Honeycomb namespace.
static Real acos(Real x)
Convert cosine ratio [-1, 1] to radian angle [0, pi].
Definition: Trig.h:69
Trigonometry.
Definition: Trig.h:52
static Real atan2(Real y, Real x)
Converts Cartesian(x,y) to Polar(r, theta), and returns radian angle theta [-pi, pi].
Definition: Trig.h:76