OROCHI
 
Loading...
Searching...
No Matches
GxMath.h
Go to the documentation of this file.
1//===========================================================================
9//===========================================================================
10#pragma once
11
12#include <limits.h>
13
14GX_CORE_NAMESPACE_BEGIN()
15
16// 円周率
17static constexpr f32 PI = 3.14159265358979323846f;
18static constexpr f32 PI2 = 6.28318530717958647693f;
19static constexpr f32 PI_2 = 1.57079632679489661923f;
20static constexpr f64 PI_D = 3.14159265358979323846;
21static constexpr f64 PI2_D = 6.28318530717958647693;
22static constexpr f64 PI_2_D = 1.57079632679489661923;
23
24// 角度変換
25#define DEGREE_TO_RADIAN(degree) ((degree) * static_cast<f32>(PI / 180.0f))
26#define RADIAN_TO_DEGREE(radian) ((radian) * static_cast<f32>(180.0f / PI))
27
28// ビット⇔バイト変換
29#define BIT_TO_BYTE(__BIT__) ((__BIT__) >> 3)
30#define BYTE_TO_BIT(__BYTE__) ((__BYTE__) << 3)
31
32// 1メートル当たりの大きさ
33static constexpr f32 WORLD_METER = 1.0f;
34
36enum class AXIS
37{
38 X,
39 Y,
40 Z,
41 MAX,
42};
43#if GX_DEVELOP
44GX_ENUM_BEGIN(AXIS)
45 GX_ENUM_VALUE("X軸", AXIS::X),
46 GX_ENUM_VALUE("Y軸", AXIS::Y),
47 GX_ENUM_VALUE("Z軸", AXIS::Z),
48GX_ENUM_END()
49#endif //GX_DEVELOP
50
52enum class INIT
53{
54 NONE,
55 ZERO,
57};
58
63template<typename T,typename S>
64static GX_FORCE_INLINE size_t AddAddress(T address, S value)
65{
66 return static_cast<size_t>(address) + static_cast<size_t>(value);
67}
72template<typename T,typename S>
73static GX_FORCE_INLINE size_t SubAddress(T address, S value)
74{
75 return static_cast<size_t>(address) - static_cast<size_t>(value);
76}
77
78struct GxVector3;
79
80//===========================================================================
82//===========================================================================
83class GxMath : public GxClassBase
84{
85 //-----------------------------------------------------------
87 //-----------------------------------------------------------
89public:
90 GX_RTTI_ABSTRACT_CLASS(GxMath, GxClassBase)
91 // ClassBase継承クラス用禁止宣言
93
94
95 enum class PREFIX
96 {
97 NANO = -9,
98 MICRO = -6,
99 MILLI = -3,
100 ZERO = 0,
101 KILO = 3,
102 MEGA = 6,
103 GIGA = 9,
104 };
106 static constexpr u32 NANO_INVERSE = 1000000000;
108 static constexpr u32 MICRO_INVERSE = 1000000;
110 static constexpr u32 MILLI_INVERSE = 1000;
112 static constexpr u32 KILO_VALUE = 1000;
114 static constexpr u32 MEGA_VALUE = 1000000;
116 static constexpr u32 GIGA_VALUE = 1000000000;
117
118 // 汎用数値定義
119 static constexpr u32 VALUE_1 = 0x00000001;
120 static constexpr u32 VALUE_2 = 0x00000002;
121 static constexpr u32 VALUE_4 = 0x00000004;
122 static constexpr u32 VALUE_8 = 0x00000008;
123 static constexpr u32 VALUE_16 = 0x00000010;
124 static constexpr u32 VALUE_32 = 0x00000020;
125 static constexpr u32 VALUE_64 = 0x00000040;
126 static constexpr u32 VALUE_128 = 0x00000080;
127 static constexpr u32 VALUE_256 = 0x00000100;
128 static constexpr u32 VALUE_512 = 0x00000200;
129 static constexpr u32 VALUE_1K = 0x00000400;
130 static constexpr u32 VALUE_2K = 0x00000800;
131 static constexpr u32 VALUE_4K = 0x00001000;
132 static constexpr u32 VALUE_8K = 0x00002000;
133 static constexpr u32 VALUE_16K = 0x00004000;
134 static constexpr u32 VALUE_32K = 0x00008000;
135 static constexpr u32 VALUE_64K = 0x00010000;
136 static constexpr u32 VALUE_128K = 0x00020000;
137 static constexpr u32 VALUE_256K = 0x00040000;
138 static constexpr u32 VALUE_512K = 0x00080000;
139 static constexpr u32 VALUE_1M = 0x00100000;
140 static constexpr u32 VALUE_2M = 0x00200000;
141 static constexpr u32 VALUE_4M = 0x00400000;
142 static constexpr u32 VALUE_8M = 0x00800000;
143 static constexpr u32 VALUE_16M = 0x01000000;
144 static constexpr u32 VALUE_32M = 0x02000000;
145 static constexpr u32 VALUE_64M = 0x04000000;
146 static constexpr u32 VALUE_128M = 0x08000000;
147 static constexpr u32 VALUE_256M = 0x10000000;
148 static constexpr u32 VALUE_512M = 0x20000000;
149 static constexpr u32 VALUE_1G = 0x40000000;
150 static constexpr u32 VALUE_2G = 0x80000000;
151
153 //-----------------------------------------------------------
155 //-----------------------------------------------------------
157private:
159 GxMath(void) {}
160
162 //-----------------------------------------------------------
164 //-----------------------------------------------------------
166public:
168 template<class T> GX_FORCE_INLINE static T getAbs(const T value){ return ( value < 0 ) ? -value : value; }
170 template<class T> GX_FORCE_INLINE static T getClamp(const T value, const T min, const T max){ return getMax(min, getMin(value, max)); }
172 template<class T> GX_FORCE_INLINE static T getMin(const T value0, const T value1){ return value0 < value1 ? value0 : value1; }
174 template<class T> GX_FORCE_INLINE static T getMax(const T value0, const T value1){ return value0 < value1 ? value1 : value0; }
176 template<class T> GX_FORCE_INLINE static T getLerp(const T value0, const T value1, f32 ratio){ return static_cast<T>(ratio * value1 + (1.f - ratio) * value0); }
178 template<class T> GX_FORCE_INLINE static void swap(T& a, T& b){ T c = a; a = b; b = c; }
180 static f32 getLoop(f32 value, f32 min, f32 max);
182 GX_FORCE_INLINE static f32 getLoopPI(f32 value){ return getLoop(value, -PI, PI); }
184 GX_FORCE_INLINE static f32 getLoopPI2(f32 value){ return getLoop(value, 0, PI2); }
186 static constexpr s32 getSign(s32 value){ return value < 0 ? -1 : (value > 0 ? 1 : 0); }
188 static constexpr f32 getSign(f32 value){ return value < 0.f ? -1.f : (value > 0.f ? 1.f : 0.f); }
190 static constexpr f32 getDegree(f32 radian) { return radian * (180.0f / PI); }
192 static constexpr f64 getDegree(f64 radian) { return radian * (180.0 / PI_D); }
194 static constexpr f32 getRadian(f32 degree) { return degree * (PI / 180.0f); }
196 static constexpr f64 getRadian(f64 degree) { return degree * (PI_D / 180.0); }
198 static f32 getMinRadian(f32 radian);
200 GX_FORCE_INLINE static f32 getSaturate(const f32 value);
202 GX_FORCE_INLINE static f64 getSaturate(const f64 value);
203
205 GX_FORCE_INLINE static f32 getSin(const f32 radian){ return sinf(radian); }
207 GX_FORCE_INLINE static f64 getSin(const f64 radian){ return sin(radian); }
209 GX_FORCE_INLINE static f32 getFastSin(const f32 radian){ return sinf(radian); }
210
212 GX_FORCE_INLINE static f32 getCos(const f32 radian){ return cosf(radian); }
214 GX_FORCE_INLINE static f64 getCos(const f64 radian){ return cos(radian); }
216 GX_FORCE_INLINE static f32 getFastCos(const f32 radian){ return cosf(radian); }
217
219 GX_FORCE_INLINE static f32 getTan(const f32 radian){ return tanf(radian); }
221 GX_FORCE_INLINE static f64 getTan(const f64 radian){ return tan(radian); }
223 GX_FORCE_INLINE static f32 getFastTan(const f32 radian){ return tanf(radian); }
224
226 GX_FORCE_INLINE static f32 getASin(const f32 value){ return asinf(value); }
228 GX_FORCE_INLINE static f64 getASin(const f64 value){ return asin(value); }
230 GX_FORCE_INLINE static f32 getFastASin(const f32 value){ return asinf(value); }
231
233 GX_FORCE_INLINE static f32 getACos(const f32 value){ return acosf(value); }
235 GX_FORCE_INLINE static f64 getACos(const f64 value){ return acos(value); }
237 GX_FORCE_INLINE static f32 getFastACos(const f32 value){ return acosf(value); }
238
240 GX_FORCE_INLINE static f32 getATan(const f32 value){ return atanf(value); }
242 GX_FORCE_INLINE static f64 getATan(const f64 value){ return atan(value); }
244 GX_FORCE_INLINE static f32 getFastATan(const f32 value){ return atanf(value); }
245
247 GX_FORCE_INLINE static f32 getATan2(const f32 valueY, const f32 valueX){ return atan2f(valueY, valueX); }
249 GX_FORCE_INLINE static f64 getATan2(const f64 valueY, const f64 valueX){ return atan2(valueY, valueX); }
251 GX_FORCE_INLINE static f32 getFastATan2(const f32 valueY, const f32 valueX){ return atan2f(valueY, valueX); }
252
254 GX_FORCE_INLINE static f32 getSqrtInverse(const f32 value){ return 1.0f / sqrtf(value); }
256 GX_FORCE_INLINE static f64 getSqrtInverse(const f64 value){ return 1.0 / sqrt(value); }
257
259 GX_FORCE_INLINE static f32 getSqrt(const f32 value){ return sqrtf(value); }
261 GX_FORCE_INLINE static f64 getSqrt(const f64 value){ return sqrt(value); }
262
264 GX_FORCE_INLINE static f32 getLog(const f32 value){ return logf(value); }
266 GX_FORCE_INLINE static f64 getLog(const f64 value){ return log(value); }
268 GX_FORCE_INLINE static f32 getLog(const f32 value, const f32 base){ return logf(value) / logf(base); }
270 GX_FORCE_INLINE static f64 getLog(const f64 value, const f64 base){ return log(value) / log(base); }
271
273 GX_FORCE_INLINE static f32 getPow(const f32 value, const f32 n){ return powf(value, n); }
275 GX_FORCE_INLINE static f64 getPow(const f64 value, const f64 n){ return pow(value, n); }
276
278 GX_FORCE_INLINE static f32 getExp(const f32 n){ return expf(n); }
280 GX_FORCE_INLINE static f64 getExp(const f64 n){ return exp(n); }
282 GX_FORCE_INLINE static f32 getFastExp(const f32 n){ return expf(n); }
283
285 static u32 getLog(u32 value, const u32 base = 2);
287 static u64 getPow(const u32 value, const u32 n);
289 static u32 getFigure(const s64 value);
291 static u32 getFigure(const u64 value);
293 static u32 getHash32(void* pData, u32 size);
295 static u32 getHash32(GX_CSTR string);
297 static u32 getHash32(GX_CSTR string, u32 value);
299 static u32 getHash32Encrypt(GX_CSTR string);
301 static u32 getHash32(GX_CWSTR string);
303 static u32 getHash32(GX_CWSTR string, u32 value);
305 static u32 getHash32Encrypt(GX_CWSTR string);
307 static u64 getHash64(void* pData, u32 size);
309 static u64 getHash64Fast(void* pData, u32 size);
311 static u64 getHash64(GX_CSTR string);
313 static u64 getHash64(GX_CWSTR string);
315 static u32 addHash32(u32 hash, u32 value);
317 template<class T>GX_FORCE_INLINE static T getReverseEndian16(T value);
319 template<class T>GX_FORCE_INLINE static T getReverseEndian32(T value);
321 template<class T>GX_FORCE_INLINE static T getReverseEndian64(T value);
323 template<class T>GX_FORCE_INLINE static T getReverseEndian128(T value);
325 GX_FORCE_INLINE static u32 getBitCount(u32 value);
327 template<class T> GX_FORCE_INLINE static b32 isPowerOfTwo(T value);
329 template<class T> GX_FORCE_INLINE static b32 isAlignment(T value, u32 alignment);
331 template<class T> GX_FORCE_INLINE static b32 isAlignmentFast(T value, u32 alignment);
333 template<class T> GX_FORCE_INLINE static T getRoundUp(T value, u32 alignment);
335 template<class T> GX_FORCE_INLINE static T getRoundDown(T value, u32 alignment);
337 template<class T> GX_FORCE_INLINE static T getRoundUpFast(T value, size_t alignment);
339 template<class T> GX_FORCE_INLINE static T getRoundDownFast(T value, u32 alignment);
341 template<class T> GX_FORCE_INLINE static T getRoundUpPowerOfTwo(T value);
343 GX_FORCE_INLINE static f32 getFloor( f32 value ){ return static_cast<f32>(floor(value)); }
345 GX_FORCE_INLINE static f64 getFloor( f64 value ){ return floor(value); }
347 GX_FORCE_INLINE static f32 getCeil( f32 value ){ return static_cast<f32>(ceil(value)); }
349 GX_FORCE_INLINE static f64 getCeil( f64 value ){ return ceil(value); }
350
352 static void calculateSplineTangent(const GxVector3& position0, const GxVector3& position1, const GxVector3& position2, const f32 time, GxVector3& direct);
354 static void calculateSplinePosition(const GxVector3& position0, const GxVector3& position1, const GxVector3& position2, const f32 time, GxVector3& position);
356 static void calculateBezierTangent(const GxVector3& position0, const GxVector3& position1, const GxVector3& position2, const GxVector3& position3, const f32 time, GxVector3& direct);
358 static void calculateBezierPosition(const GxVector3& position0, const GxVector3& position1, const GxVector3& position2, const GxVector3& position3, const f32 time, GxVector3& position);
359
361 template<class T> static void geoCoordinatesToMeter(T longitude, T latitude, T centerLongitude, T centerLatitude, T& xMeter, T& zMeter);
362
364 static u32 getRandom(u32 value);
365
367};
368
369//---------------------------------------------------------------------------
370// 0.0f~1.0の範囲にクランプした値を取得(f32)
373//---------------------------------------------------------------------------
374GX_FORCE_INLINE f32 GxMath::getSaturate(const f32 value)
375{
376 return getClamp(value, 0.0f, 1.0f);
377}
378
379//---------------------------------------------------------------------------
380// 0.0f~1.0の範囲にクランプした値を取得(f64)
383//---------------------------------------------------------------------------
384GX_FORCE_INLINE f64 GxMath::getSaturate(const f64 value)
385{
386 return getClamp(value, 0.0, 1.0);
387}
388
389//---------------------------------------------------------------------------
390// エンディアン変換した値を取得(16bit版)
393//---------------------------------------------------------------------------
394template<class T>
395GX_FORCE_INLINE T GxMath::getReverseEndian16(T value)
396{
397 return ((value & 0xff00) >> 8) | ((value & 0x00ff) << 8);
398}
399
400//---------------------------------------------------------------------------
401// エンディアン変換した値を取得(32bit版)
404//---------------------------------------------------------------------------
405template<class T>
406GX_FORCE_INLINE T GxMath::getReverseEndian32(T value)
407{
408 auto temporary = *reinterpret_cast<u32*>(&value);
409 temporary = ((temporary & 0xff000000) >> 24) |
410 ((temporary & 0x00ff0000) >> 8) |
411 ((temporary & 0x0000ff00) << 8) |
412 ((temporary & 0x000000ff) << 24);
413 auto result = *reinterpret_cast<T*>(&temporary);
414 return result;
415}
416
417//---------------------------------------------------------------------------
418// エンディアン変換した値を取得(64bit版)
421//---------------------------------------------------------------------------
422template<class T>
423GX_FORCE_INLINE T GxMath::getReverseEndian64(T value)
424{
425 auto temporary = *reinterpret_cast<u64*>(&value);
426 temporary = ((temporary & 0xff00000000000000ULL) >> 56) |
427 ((temporary & 0x00ff000000000000ULL) >> 40) |
428 ((temporary & 0x0000ff0000000000ULL) >> 24) |
429 ((temporary & 0x000000ff00000000ULL) >> 8) |
430 ((temporary & 0x00000000ff000000ULL) << 8) |
431 ((temporary & 0x0000000000ff0000ULL) << 24) |
432 ((temporary & 0x000000000000ff00ULL) << 40) |
433 ((temporary & 0x00000000000000ffULL) << 56);
434 auto result = *reinterpret_cast<T*>(&temporary);
435 return result;
436}
437
438//---------------------------------------------------------------------------
439// エンディアン変換した値を取得(128bit版)
442//---------------------------------------------------------------------------
443template<class T>
444GX_FORCE_INLINE T GxMath::getReverseEndian128(T value)
445{
446 u8 temporary[16];
447 auto* pSrc = reinterpret_cast<u8*>(&value);
448 for (u32 i = 0; i < 16; i++)
449 {
450 temporary[i] = pSrc[15 - i];
451 }
452 auto result = *reinterpret_cast<T*>(temporary);
453 return result;
454}
455
456//---------------------------------------------------------------------------
457// 1の立っているビット数取得
460//---------------------------------------------------------------------------
461GX_FORCE_INLINE u32 GxMath::getBitCount(u32 value)
462{
463 value = ((value >> 1) & 0x55555555) + (value & 0x55555555);
464 value = ((value >> 2) & 0x33333333) + (value & 0x33333333);
465 value = ((value >> 4) & 0x0F0F0F0F) + (value & 0x0F0F0F0F);
466 value = ((value >> 8) & 0x00FF00FF) + (value & 0x00FF00FF);
467 value = ((value >>16) & 0x0000FFFF) + (value & 0x0000FFFF);
468 return value;
469}
470
471//---------------------------------------------------------------------------
472// 2のべき乗判定
474//---------------------------------------------------------------------------
475template<class T>
476GX_FORCE_INLINE b32 GxMath::isPowerOfTwo(T value)
477{
478 return !(static_cast<size_t>(value) & (static_cast<size_t>(value) - 1));
479}
480
481//---------------------------------------------------------------------------
482// アライメント判定
486//---------------------------------------------------------------------------
487template<class T>
488GX_FORCE_INLINE b32 GxMath::isAlignment(T value, u32 alignment)
489{
490 return !((size_t)value % alignment);
491}
492
493//---------------------------------------------------------------------------
494// アライメント判定(高速版 ※2のべき乗指定)
498//---------------------------------------------------------------------------
499template<class T>
500GX_FORCE_INLINE b32 GxMath::isAlignmentFast(T value, u32 alignment)
501{
502 GX_ASSERT(isPowerOfTwo(alignment), "argument error!! alignment(%d) is not power of two", alignment);
503 return !((size_t)value & (alignment - 1));
504}
505
506//---------------------------------------------------------------------------
507// 数値切り上げ
511//---------------------------------------------------------------------------
512template<class T>
513GX_FORCE_INLINE T GxMath::getRoundUp(T value, u32 alignment)
514{
515 return ((size_t)value % alignment)? (T)(static_cast<size_t>(value) + alignment - (static_cast<size_t>(value) % alignment)) : value;
516}
517
518//---------------------------------------------------------------------------
519// 数値切り捨て
523//---------------------------------------------------------------------------
524template<class T>
525GX_FORCE_INLINE T GxMath::getRoundDown(T value, u32 alignment)
526{
527 return (value % alignment)? (T)(static_cast<size_t>(value) - (static_cast<size_t>(value) % alignment)) : value;
528}
529
530//---------------------------------------------------------------------------
531// 数値切り上げ(高速版 ※2のべき乗指定)
535//---------------------------------------------------------------------------
536template<class T>
537GX_FORCE_INLINE T GxMath::getRoundUpFast(T value, size_t alignment)
538{
539 GX_ASSERT(isPowerOfTwo(alignment), "argument error!! alignment(%d) is not power of two", alignment);
540 return (T)(((size_t)value + (alignment - 1)) & ~(alignment - 1));
541}
542
543//---------------------------------------------------------------------------
544// 数値切り捨て(高速版 ※2のべき乗指定)
548//---------------------------------------------------------------------------
549template<class T>
550GX_FORCE_INLINE T GxMath::getRoundDownFast(T value, u32 alignment)
551{
552 GX_ASSERT(isPowerOfTwo(alignment), "argument error!! alignment(%d) is not power of two", alignment);
553 return static_cast<T>(value & ~(static_cast<T>(alignment) - 1));
554}
555
556//---------------------------------------------------------------------------
557// 2のべき乗に切り上げ
560//---------------------------------------------------------------------------
561template<class T>
562GX_FORCE_INLINE T GxMath::getRoundUpPowerOfTwo(T value)
563{
564 T target = 2;
565 while (target < value)
566 {
567 target = target << 1;
568 }
569 return target;
570}
571
572//---------------------------------------------------------------------------
573// 緯度経度からメートルに変換
580//---------------------------------------------------------------------------
581template<class T>
582void GxMath::geoCoordinatesToMeter(T longitude, T latitude, T centerLongitude, T centerLatitude, T& xMeter, T& zMeter)
583{
584 const T a = 6378137;
585 const T F = 298.257222101;
586 const T e2 = (2 * F - 1) / F / F;
587
588 T nLatitude = GxMath::getRadian((longitude + centerLongitude) / 2.0);
589 T dLatitude = GxMath::getRadian(longitude - centerLongitude);
590 T dLongitude = GxMath::getRadian(latitude - centerLatitude);
591
592 T sinValue = GxMath::getSin(nLatitude);
593 T cosValue = GxMath::getCos(nLatitude);
594
595 T w = GxMath::getSqrt(1 - e2 * sinValue * sinValue);
596 T n = a / w;
597 T m = a * (1 - e2) / (w * w * w);
598
599 xMeter = dLongitude * n * cosValue;
600 zMeter = -dLatitude * m;
601}
602
603// RTTIやプロパティなどの文字列からIDを作成するマクロ
604#define HASH_CONST_VALUE 37
605#define MAKE_ID_NAME_LENGTH_MAX UCHAR_MAX
606
607GX_CORE_NAMESPACE_END()
#define GX_PROHIBIT_CLASS_BASE(__CLASS__)
GxClassBase継承の禁止宣言
Definition GxBase.h:240
INIT
初期化タイプ
Definition GxMath.h:53
@ ZERO
全て 0 で初期化
@ NONE
何もしない
@ IDENTITY
基礎値で初期化
AXIS
軸方向
Definition GxMath.h:37
@ X
X.
@ Z
Z.
@ MAX
定義数
@ Y
Y.
オブジェクト基底クラス
Definition GxBase.h:88
算術演算クラス
Definition GxMath.h:84
static GX_FORCE_INLINE T getRoundUp(T value, u32 alignment)
数値切り上げ
Definition GxMath.h:513
static GX_FORCE_INLINE T getRoundDownFast(T value, u32 alignment)
数値切り捨て(高速版 ※2のべき乗指定)
Definition GxMath.h:550
static GX_FORCE_INLINE b32 isPowerOfTwo(T value)
2のべき乗判定
Definition GxMath.h:476
static constexpr u32 VALUE_32
32
Definition GxMath.h:124
static u32 getHash32(void *pData, u32 size)
ハッシュ値取得(32bit、データ、サイズ指定版)
Definition GxMath.cpp:241
static GX_FORCE_INLINE f64 getFloor(f64 value)
GX用floor(f64用切捨て)
Definition GxMath.h:345
static constexpr u32 VALUE_2M
2M
Definition GxMath.h:140
static constexpr u32 VALUE_512M
512M
Definition GxMath.h:148
static constexpr u32 VALUE_4
4
Definition GxMath.h:121
static constexpr u32 VALUE_256K
256K
Definition GxMath.h:137
static constexpr u32 VALUE_32M
32M
Definition GxMath.h:144
static constexpr u32 NANO_INVERSE
ナノの逆数
Definition GxMath.h:106
static GX_FORCE_INLINE f32 getFloor(f32 value)
GX用floor(f32用切捨て)
Definition GxMath.h:343
static GX_FORCE_INLINE T getClamp(const T value, const T min, const T max)
最小値・最大値で切り落とす
Definition GxMath.h:170
static constexpr u32 KILO_VALUE
キロの値
Definition GxMath.h:112
static constexpr u32 VALUE_512
512
Definition GxMath.h:128
static constexpr f32 getSign(f32 value)
符号を取得
Definition GxMath.h:188
static constexpr u32 VALUE_128K
128K
Definition GxMath.h:136
static GX_FORCE_INLINE f32 getFastTan(const f32 radian)
正接を取得(FPU, f32)
Definition GxMath.h:223
static constexpr u32 VALUE_1K
1K
Definition GxMath.h:129
static GX_FORCE_INLINE f32 getCos(const f32 radian)
余弦を取得(f32)
Definition GxMath.h:212
static f32 getLoop(f32 value, f32 min, f32 max)
余剰を計算して[min,max)の範囲に収める
Definition GxMath.cpp:112
static GX_FORCE_INLINE f32 getLoopPI(f32 value)
余剰を計算して[-π,π)の範囲に収める
Definition GxMath.h:182
static constexpr f32 getDegree(f32 radian)
角度(度数法)を取得
Definition GxMath.h:190
static constexpr u32 MICRO_INVERSE
マイクロの逆数
Definition GxMath.h:108
static constexpr s32 getSign(s32 value)
符号を取得
Definition GxMath.h:186
static constexpr u32 VALUE_256M
256M
Definition GxMath.h:147
static GX_FORCE_INLINE f32 getTan(const f32 radian)
正接を取得(f32)
Definition GxMath.h:219
static GX_FORCE_INLINE T getReverseEndian128(T value)
エンディアン変換した値を取得(128bit版)
Definition GxMath.h:444
static constexpr u32 VALUE_1G
1G
Definition GxMath.h:149
static u64 getHash64(void *pData, u32 size)
ハッシュ値取得(64bit、データ、サイズ指定版)
Definition GxMath.cpp:342
static constexpr u32 VALUE_2
2
Definition GxMath.h:120
static GX_FORCE_INLINE f64 getATan(const f64 value)
逆正接を取得(f64)
Definition GxMath.h:242
static constexpr u32 VALUE_2K
2K
Definition GxMath.h:130
static constexpr u32 MILLI_INVERSE
ミリの逆数
Definition GxMath.h:110
static GX_FORCE_INLINE f32 getACos(const f32 value)
逆余弦を取得(f32)
Definition GxMath.h:233
static constexpr u32 VALUE_16
16
Definition GxMath.h:123
static void calculateBezierTangent(const GxVector3 &position0, const GxVector3 &position1, const GxVector3 &position2, const GxVector3 &position3, const f32 time, GxVector3 &direct)
ベジェの接線方向を計算
Definition GxMath.cpp:445
static GX_FORCE_INLINE f32 getFastATan(const f32 value)
逆正接を取得(FPU, f32)
Definition GxMath.h:244
static GX_FORCE_INLINE f32 getLog(const f32 value)
対数を取得(f32)
Definition GxMath.h:264
static GX_FORCE_INLINE f64 getCos(const f64 radian)
余弦を取得(f64)
Definition GxMath.h:214
static GX_FORCE_INLINE f32 getASin(const f32 value)
逆正弦を取得(f32)
Definition GxMath.h:226
static GX_FORCE_INLINE f32 getExp(const f32 n)
自然対数のn乗を取得(f32)
Definition GxMath.h:278
static u32 addHash32(u32 hash, u32 value)
既存の取得ハッシュに新たに値を加える(stringの後にs32を考慮したい場合などに使用)
Definition GxMath.cpp:259
static constexpr f32 getRadian(f32 degree)
角度(弧度法)を取得
Definition GxMath.h:194
static GX_FORCE_INLINE f64 getTan(const f64 radian)
正接を取得(f64)
Definition GxMath.h:221
static GX_FORCE_INLINE b32 isAlignment(T value, u32 alignment)
アライメント判定
Definition GxMath.h:488
static GX_FORCE_INLINE f64 getLog(const f64 value, const f64 base)
対数を取得(f64)
Definition GxMath.h:270
static void geoCoordinatesToMeter(T longitude, T latitude, T centerLongitude, T centerLatitude, T &xMeter, T &zMeter)
緯度経度からメートルに変換
Definition GxMath.h:582
static GX_FORCE_INLINE u32 getBitCount(u32 value)
1の立っているビット数取得
Definition GxMath.h:461
static GX_FORCE_INLINE T getRoundDown(T value, u32 alignment)
数値切り捨て
Definition GxMath.h:525
static GX_FORCE_INLINE f64 getExp(const f64 n)
自然対数のn乗を取得(f64)
Definition GxMath.h:280
static constexpr u32 VALUE_16K
16K
Definition GxMath.h:133
static constexpr u32 MEGA_VALUE
メガの値
Definition GxMath.h:114
static constexpr u32 VALUE_256
256
Definition GxMath.h:127
static u64 getHash64Fast(void *pData, u32 size)
ハッシュ値取得(64bit、データ、サイズ指定、高速版)
Definition GxMath.cpp:359
static constexpr u32 VALUE_1
1
Definition GxMath.h:119
static constexpr u32 VALUE_1M
1M
Definition GxMath.h:139
static GX_FORCE_INLINE f64 getCeil(f64 value)
GX用Ceil(f64用切上げ)
Definition GxMath.h:349
static GX_FORCE_INLINE T getRoundUpPowerOfTwo(T value)
2のべき乗に切り上げ
Definition GxMath.h:562
static constexpr u32 VALUE_4K
4K
Definition GxMath.h:131
static void calculateSplinePosition(const GxVector3 &position0, const GxVector3 &position1, const GxVector3 &position2, const f32 time, GxVector3 &position)
スプラインの位置を計算
Definition GxMath.cpp:431
static GX_FORCE_INLINE T getLerp(const T value0, const T value1, f32 ratio)
線形補間を取得
Definition GxMath.h:176
static GX_FORCE_INLINE f64 getSin(const f64 radian)
正弦を取得(f64)
Definition GxMath.h:207
static GX_FORCE_INLINE void swap(T &a, T &b)
2つの値をスワップ
Definition GxMath.h:178
static void calculateSplineTangent(const GxVector3 &position0, const GxVector3 &position1, const GxVector3 &position2, const f32 time, GxVector3 &direct)
スプラインの接線方向を計算
Definition GxMath.cpp:415
static constexpr u32 VALUE_32K
32K
Definition GxMath.h:134
static GX_FORCE_INLINE T getRoundUpFast(T value, size_t alignment)
数値切り上げ(高速版 ※2のべき乗指定)
Definition GxMath.h:537
static constexpr u32 VALUE_64K
64K
Definition GxMath.h:135
static GX_FORCE_INLINE T getReverseEndian16(T value)
エンディアン変換した値を取得(16bit版)
Definition GxMath.h:395
static GX_FORCE_INLINE f32 getATan2(const f32 valueY, const f32 valueX)
逆正接を取得(f32)
Definition GxMath.h:247
static GX_FORCE_INLINE f32 getSqrtInverse(const f32 value)
平方根の逆数を取得(f32)
Definition GxMath.h:254
static GX_FORCE_INLINE b32 isAlignmentFast(T value, u32 alignment)
アライメント判定(高速版 ※2のべき乗指定)
Definition GxMath.h:500
static void calculateBezierPosition(const GxVector3 &position0, const GxVector3 &position1, const GxVector3 &position2, const GxVector3 &position3, const f32 time, GxVector3 &position)
ベジエの位置を計算
Definition GxMath.cpp:462
static GX_FORCE_INLINE f32 getFastCos(const f32 radian)
余弦を取得(FPU, f32)
Definition GxMath.h:216
static u32 getHash32Encrypt(GX_CSTR string)
ハッシュ値取得(32bit、文字列指定、暗号化版)
Definition GxMath.cpp:297
static constexpr f64 getRadian(f64 degree)
角度(弧度法)を取得
Definition GxMath.h:196
static constexpr u32 VALUE_16M
16M
Definition GxMath.h:143
static constexpr u32 VALUE_512K
512K
Definition GxMath.h:138
static GX_FORCE_INLINE f64 getACos(const f64 value)
逆余弦を取得(f64)
Definition GxMath.h:235
static constexpr u32 VALUE_2G
2G
Definition GxMath.h:150
static constexpr u32 VALUE_4M
4M
Definition GxMath.h:141
static GX_FORCE_INLINE T getReverseEndian64(T value)
エンディアン変換した値を取得(64bit版)
Definition GxMath.h:423
static GX_FORCE_INLINE f64 getLog(const f64 value)
対数を取得(f64)
Definition GxMath.h:266
static GX_FORCE_INLINE f32 getSqrt(const f32 value)
平方根を取得(f32)
Definition GxMath.h:259
static constexpr u32 VALUE_8M
8M
Definition GxMath.h:142
static constexpr u32 VALUE_8
8
Definition GxMath.h:122
static constexpr u32 VALUE_64M
64M
Definition GxMath.h:145
static GX_FORCE_INLINE f32 getFastExp(const f32 n)
自然対数のn乗を取得(FPU, f32)
Definition GxMath.h:282
static GX_FORCE_INLINE f32 getCeil(f32 value)
GX用Ceil(f32用切上げ)
Definition GxMath.h:347
static GX_FORCE_INLINE T getAbs(const T value)
絶対値
Definition GxMath.h:168
static GX_FORCE_INLINE f64 getSqrt(const f64 value)
平方根を取得(f64)
Definition GxMath.h:261
static GX_FORCE_INLINE f32 getFastATan2(const f32 valueY, const f32 valueX)
逆正接を取得(FPU, f32)
Definition GxMath.h:251
static GX_FORCE_INLINE T getMax(const T value0, const T value1)
大きいほうを取得
Definition GxMath.h:174
static constexpr u32 VALUE_128
128
Definition GxMath.h:126
static GX_FORCE_INLINE f32 getFastASin(const f32 value)
逆正弦を取得(FPU, f32)
Definition GxMath.h:230
static constexpr u32 VALUE_128M
128M
Definition GxMath.h:146
static constexpr u32 GIGA_VALUE
ギガの値
Definition GxMath.h:116
static GX_FORCE_INLINE f32 getFastACos(const f32 value)
逆余弦を取得(FPU, f32)
Definition GxMath.h:237
static GX_FORCE_INLINE T getMin(const T value0, const T value1)
小さいほうを取得
Definition GxMath.h:172
PREFIX
単位接頭辞の定義
Definition GxMath.h:96
@ MICRO
マイクロ
static constexpr u32 VALUE_8K
8K
Definition GxMath.h:132
static GX_FORCE_INLINE f32 getFastSin(const f32 radian)
正弦を取得(FPU, f32)
Definition GxMath.h:209
static u32 getRandom(u32 value)
値未満の乱数を取得
Definition GxMath.cpp:472
static GX_FORCE_INLINE f64 getATan2(const f64 valueY, const f64 valueX)
逆正接を取得(f64)
Definition GxMath.h:249
static u32 getFigure(const s64 value)
桁数を取得
Definition GxMath.cpp:194
static constexpr f64 getDegree(f64 radian)
角度(度数法)を取得
Definition GxMath.h:192
static GX_FORCE_INLINE f64 getASin(const f64 value)
逆正弦を取得(f64)
Definition GxMath.h:228
static GX_FORCE_INLINE f32 getLog(const f32 value, const f32 base)
対数を取得(f32)
Definition GxMath.h:268
static constexpr u32 VALUE_64
64
Definition GxMath.h:125
static GX_FORCE_INLINE T getReverseEndian32(T value)
エンディアン変換した値を取得(32bit版)
Definition GxMath.h:406
static GX_FORCE_INLINE f32 getSin(const f32 radian)
正弦を取得(f32)
Definition GxMath.h:205
static GX_FORCE_INLINE f64 getSqrtInverse(const f64 value)
平方根の逆数を取得(f64)
Definition GxMath.h:256
static GX_FORCE_INLINE f32 getATan(const f32 value)
逆正接を取得(f32)
Definition GxMath.h:240
static GX_FORCE_INLINE f64 getPow(const f64 value, const f64 n)
n乗を取得(f64)
Definition GxMath.h:275
static GX_FORCE_INLINE f32 getLoopPI2(f32 value)
余剰を計算して[0,2π)の範囲に収める
Definition GxMath.h:184
static GX_FORCE_INLINE f32 getPow(const f32 value, const f32 n)
n乗を取得(f32)
Definition GxMath.h:273
static f32 getMinRadian(f32 radian)
ラジアンの絶対値を最小にして取得
Definition GxMath.cpp:134
static GX_FORCE_INLINE f32 getSaturate(const f32 value)
0.0f~1.0の範囲にクランプした値を取得(f32)
Definition GxMath.h:374
3次元ベクトル
Definition GxVector.h:245
32bitブーリアン
Definition GxDefine.h:173