Plasma Engine
2.0
Loading...
Searching...
No Matches
MathFixedPoint_inl.h
1
#pragma once
2
3
#include <Foundation/Math/FixedPoint.h>
4
5
/*
6
namespace plMath
7
{
8
#define FIXEDPOINT_OVERLOADS(Bits) \
9
template <> \
10
PL_ALWAYS_INLINE plFixedPoint<Bits> BasicType<plFixedPoint<Bits>>::MaxValue() { return (plFixedPoint<Bits>)((1 << (31 - Bits)) - 1); } \
11
template <> \
12
PL_ALWAYS_INLINE plFixedPoint<Bits> BasicType<plFixedPoint<Bits>>::SmallEpsilon() { return (plFixedPoint<Bits>)0.0001; } \
13
template <> \
14
PL_ALWAYS_INLINE plFixedPoint<Bits> BasicType<plFixedPoint<Bits>>::DefaultEpsilon() { return (plFixedPoint<Bits>)0.001; } \
15
template <> \
16
PL_ALWAYS_INLINE plFixedPoint<Bits> BasicType<plFixedPoint<Bits>>::LargeEpsilon() { return (plFixedPoint<Bits>)0.01; } \
17
template <> \
18
PL_ALWAYS_INLINE plFixedPoint<Bits> BasicType<plFixedPoint<Bits>>::HugeEpsilon() { return (plFixedPoint<Bits>)0.1; }
19
20
FIXEDPOINT_OVERLOADS(1);
21
FIXEDPOINT_OVERLOADS(2);
22
FIXEDPOINT_OVERLOADS(3);
23
FIXEDPOINT_OVERLOADS(4);
24
FIXEDPOINT_OVERLOADS(5);
25
FIXEDPOINT_OVERLOADS(6);
26
FIXEDPOINT_OVERLOADS(7);
27
FIXEDPOINT_OVERLOADS(8);
28
FIXEDPOINT_OVERLOADS(9);
29
FIXEDPOINT_OVERLOADS(10);
30
FIXEDPOINT_OVERLOADS(11);
31
FIXEDPOINT_OVERLOADS(12);
32
FIXEDPOINT_OVERLOADS(13);
33
FIXEDPOINT_OVERLOADS(14);
34
FIXEDPOINT_OVERLOADS(15);
35
FIXEDPOINT_OVERLOADS(16);
36
FIXEDPOINT_OVERLOADS(17);
37
FIXEDPOINT_OVERLOADS(18);
38
FIXEDPOINT_OVERLOADS(19);
39
FIXEDPOINT_OVERLOADS(20);
40
FIXEDPOINT_OVERLOADS(21);
41
FIXEDPOINT_OVERLOADS(22);
42
FIXEDPOINT_OVERLOADS(23);
43
FIXEDPOINT_OVERLOADS(24);
44
FIXEDPOINT_OVERLOADS(25);
45
FIXEDPOINT_OVERLOADS(26);
46
FIXEDPOINT_OVERLOADS(27);
47
FIXEDPOINT_OVERLOADS(28);
48
FIXEDPOINT_OVERLOADS(29);
49
FIXEDPOINT_OVERLOADS(30);
50
//FIXEDPOINT_OVERLOADS(31);
51
52
template <plUInt8 DecimalBits>
53
PL_FORCE_INLINE plFixedPoint<DecimalBits> Floor(plFixedPoint<DecimalBits> f)
54
{
55
PL_REPORT_FAILURE("This function is not really implemented yet.");
56
57
return (plFixedPoint<DecimalBits>)floor(f.ToDouble());
58
}
59
60
template <plUInt8 DecimalBits>
61
PL_FORCE_INLINE plFixedPoint<DecimalBits> Ceil(plFixedPoint<DecimalBits> f)
62
{
63
PL_REPORT_FAILURE("This function is not really implemented yet.");
64
65
return (plFixedPoint<DecimalBits>)ceil(f.ToDouble());
66
}
67
68
template <plUInt8 DecimalBits>
69
inline plFixedPoint<DecimalBits> Floor(plFixedPoint<DecimalBits> f, plFixedPoint<DecimalBits> fMultiple)
70
{
71
PL_REPORT_FAILURE("This function is not really implemented yet.");
72
73
plFixedPoint<DecimalBits> fDivides = f / fMultiple;
74
plFixedPoint<DecimalBits> fFactor = Floor(fDivides);
75
return fFactor * fMultiple;
76
}
77
78
template <plUInt8 DecimalBits>
79
inline plFixedPoint<DecimalBits> Ceil(plFixedPoint<DecimalBits> f, plFixedPoint<DecimalBits> fMultiple)
80
{
81
PL_REPORT_FAILURE("This function is not really implemented yet.");
82
83
plFixedPoint<DecimalBits> fDivides = f / fMultiple;
84
plFixedPoint<DecimalBits> fFactor = Ceil(fDivides);
85
return fFactor * fMultiple;
86
}
87
88
template <plUInt8 DecimalBits>
89
PL_FORCE_INLINE plFixedPoint<DecimalBits> Exp(plFixedPoint<DecimalBits> f)
90
{
91
PL_REPORT_FAILURE("This function is not really implemented yet.");
92
93
return (plFixedPoint<DecimalBits>)exp(f.ToDouble());
94
}
95
96
template <plUInt8 DecimalBits>
97
PL_FORCE_INLINE plFixedPoint<DecimalBits> Ln(plFixedPoint<DecimalBits> f)
98
{
99
PL_REPORT_FAILURE("This function is not really implemented yet.");
100
101
return (plFixedPoint<DecimalBits>)log(f.ToDouble());
102
}
103
104
template <plUInt8 DecimalBits>
105
PL_FORCE_INLINE plFixedPoint<DecimalBits> Log2(plFixedPoint<DecimalBits> f)
106
{
107
PL_REPORT_FAILURE("This function is not really implemented yet.");
108
109
return (plFixedPoint<DecimalBits>)(log10(f.ToDouble()) / log10(2.0));
110
}
111
112
template <plUInt8 DecimalBits>
113
PL_FORCE_INLINE plFixedPoint<DecimalBits> Log10(plFixedPoint<DecimalBits> f)
114
{
115
PL_REPORT_FAILURE("This function is not really implemented yet.");
116
117
return (plFixedPoint<DecimalBits>)log10(f.ToDouble());
118
}
119
120
template <plUInt8 DecimalBits>
121
PL_FORCE_INLINE plFixedPoint<DecimalBits> Log(plFixedPoint<DecimalBits> fBase, plFixedPoint<DecimalBits> f)
122
{
123
PL_REPORT_FAILURE("This function is not really implemented yet.");
124
125
return (plFixedPoint<DecimalBits>)(log10(f.ToDouble()) / log10(fBase.ToDouble()));
126
}
127
128
template <plUInt8 DecimalBits>
129
PL_FORCE_INLINE plFixedPoint<DecimalBits> Pow2(plFixedPoint<DecimalBits> f)
130
{
131
PL_REPORT_FAILURE("This function is not really implemented yet.");
132
133
return (plFixedPoint<DecimalBits>)pow(2.0, f.ToDouble());
134
}
135
136
template <plUInt8 DecimalBits>
137
PL_FORCE_INLINE plFixedPoint<DecimalBits> Pow(plFixedPoint<DecimalBits> base, plFixedPoint<DecimalBits> exp)
138
{
139
PL_REPORT_FAILURE("This function is not really implemented yet.");
140
141
return (plFixedPoint<DecimalBits>)pow(base.ToDouble(), exp.ToDouble());
142
}
143
144
template <plUInt8 DecimalBits>
145
PL_FORCE_INLINE plFixedPoint<DecimalBits> Root(plFixedPoint<DecimalBits> f, plFixedPoint<DecimalBits> NthRoot)
146
{
147
PL_REPORT_FAILURE("This function is not really implemented yet.");
148
149
return (plFixedPoint<DecimalBits>)pow(f.ToDouble(), 1.0 / NthRoot.ToDouble());
150
}
151
152
template <plUInt8 DecimalBits>
153
plFixedPoint<DecimalBits> Sqrt(plFixedPoint<DecimalBits> a)
154
{
155
return (plFixedPoint<DecimalBits>)sqrt(a.ToDouble());
156
//if (a <= plFixedPoint<DecimalBits>(0))
157
// return plFixedPoint<DecimalBits>(0);
158
159
//plFixedPoint<DecimalBits> x = a / 2;
160
161
//for (plUInt32 i = 0; i < 8; ++i)
162
//{
163
// plFixedPoint<DecimalBits> ax = a / x;
164
// plFixedPoint<DecimalBits> xpax = x + ax;
165
// x = xpax / 2;
166
//}
167
168
//return x;
169
}
170
171
template <plUInt8 DecimalBits>
172
PL_FORCE_INLINE plFixedPoint<DecimalBits> Mod(plFixedPoint<DecimalBits> f, plFixedPoint<DecimalBits> div)
173
{
174
PL_REPORT_FAILURE("This function is not really implemented yet.");
175
176
return (plFixedPoint<DecimalBits>)fmod(f.ToDouble(), div);
177
}
178
}
179
*/
Code
Engine
Foundation
Math
Implementation
MathFixedPoint_inl.h
Generated by
1.11.0