Math - SWTube/Darkest-Cave GitHub Wiki

cave.core.Math

Description

์ˆ˜ํ•™๊ณผ ๊ด€๋ จ๋œ ์—ฌ๋Ÿฌ ํ•จ์ˆ˜ ๋ฐ ์ƒ์ˆ˜๋ฅผ ์ •์˜ํ•œ ํด๋ž˜์Šค์ด๋‹ค.

Constants

Name Description
float EPSILON = 0.000001; ๋งค์šฐ ์ž‘์€ ์‹ค์ˆ˜๋ฅผ ๋‚˜ํƒ€๋‚ธ๋‹ค.
float PI = 3.141592; ์›์ฃผ์œจ ฯ€์˜ ์†Œ์ˆ˜์  6์ž๋ฆฌ ๊ทผ์‚ฌ์น˜์ด๋‹ค.
float TWO_PI = 2.f * PI; 2ฯ€
float HALF_PI = PI / 2.f; 1/2 x ฯ€
float INV_PI = 1.f / PI; 1 / ฯ€
float INV_TWO_PI = 1.f / TWO_PI; 1 / 2ฯ€
float DEG_TO_RAD = 0.0174533; ๊ฐ๋„๋ฅผ Degree์—์„œ Radian์œผ๋กœ ๋ณ€ํ™˜ํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค.
(ex. 30 degree == 0.523599 radian)
float RAD_TO_DEG = 57.2958; ๊ฐ๋„๋ฅผ Radian์—์„œ Degree๋กœ ๋ณ€ํ™˜ํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค.
(ex. 1.04719755119401 radian == 60 degree)

Member Functions

ใ…?ใ„น (๋ฏผํ•˜ ์ฃผ์˜ ์ž‘ํ’ˆ)

Name Description
GetBitCount8
GetBitCount16
GetBitCount32
GetBitCount64
GetFibonacciNumber
GetFibonacciNumberRecursive
GetMaxSizeType
GetMinSizeType

ํŒฉํ† ๋ฆฌ์–ผ

Name Description
RecursiveFactorial ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋“ค์–ด์˜จ ์ˆ˜์˜ Factorial ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
(public member function)

์‚ผ๊ฐํ•จ์ˆ˜

Name Description
float Sin(float angle) angle ํŒŒ๋ผ๋ฏธํ„ฐ์— ๋”ฐ๋ฅธ Sin ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
(public member function)
float Cos(float angle) angle ํŒŒ๋ผ๋ฏธํ„ฐ์— ๋”ฐ๋ฅธ Cos ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
(public member function)
float Tan(float angle) angle ํŒŒ๋ผ๋ฏธํ„ฐ์— ๋”ฐ๋ฅธ Tan ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
(public member function)
float ArcSin(float angle) angle ํŒŒ๋ผ๋ฏธํ„ฐ์— ๋”ฐ๋ฅธ ArcSin ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค. (Sin์˜ ์—ญํ•จ์ˆ˜)
(public member function)
float ArcCos(float angle) angle ํŒŒ๋ผ๋ฏธํ„ฐ์— ๋”ฐ๋ฅธ ArcCos ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค. (Cos์˜ ์—ญํ•จ์ˆ˜)
(public member function)
float ArcTan(float angle) angle ํŒŒ๋ผ๋ฏธํ„ฐ์— ๋”ฐ๋ฅธ ArcTan ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค. (Tan์˜ ์—ญํ•จ์ˆ˜)
(public member function)

์ฒœ์žฅ & ๋ฐ”๋‹ฅํ•จ์ˆ˜ (Wikipedia)

Name Description
int32_t Ceil(float value) value๋ณด๋‹ค ํฐ ์ •์ˆ˜ ์ค‘ ๊ฐ€์žฅ ์ž‘์€ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
(public member function)
int32_t Floor(float value) value๋ณด๋‹ค ์ž‘์€ ์ •์ˆ˜ ์ค‘ ๊ฐ€์žฅ ํฐ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
(public member function)

์ง€์ˆ˜ & ์ ˆ๋Œ€๊ฐ’

Name Description
float Exp(float value) value์— ๋”ฐ๋ฅธ e^x ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
(public member function)
int32_t Abs(int32_t value) ์ •์ˆ˜ value์˜ ์ ˆ๋Œ€๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
(public member function)
float FAbs(float value) ์‹ค์ˆ˜ value์˜ ์ ˆ๋Œ€๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
(public member function)

๋ชจ๋“ˆ๋กœ ์—ฐ์‚ฐ

Name Description
float Mod(float numerator, float denominator) numerator๋ฅผ denominator๋กœ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
(public member function)

๊ฑฐ๋“ญ์ œ๊ณฑ

Name Description
float Pow(float base, int32_t exponent) (base)^(exponent)๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
exponent์˜ ๊ฒฝ์šฐ ์ •์ˆ˜๋งŒ ์˜ฌ ์ˆ˜ ์žˆ๋‹ค.
(public member function)

์ œ๊ณฑ๊ทผ (Square Root & Inverse Square Root)

Name Description
float Sqrt(float value) sqrt(value)๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
(public member function)
float InverseSqrt(float value) 1 / sqrt(value)๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
(public member function)

๋กœ๊ทธํ•จ์ˆ˜

Name Description
float Log(float value) log(value)๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
(public member function)

๋ณด๊ฐ„๋ฒ• (Interpolation)

Name Description
float Lerp(const float one, const float other, float alpha) one๊ณผ other ์‚ฌ์ด์˜ ๊ฐ’์„ alpha์˜ ๋น„์œจ๋กœ ๊ณ„์‚ฐํ•˜์—ฌ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
(0 <= alpha < 1)
(public member function)
float NearestNeighbor(const float f0, const float f1, float t) f0๊ณผ f1 ์ค‘ ๋” ๊ฐ€๊นŒ์šด ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
(ex. NearestNeighbor(2.2, 3.9, 0.3) == 2.2
(public member function)
float CatmullRomSpline(const float f0, const float f1, const float f2, const float f3, float f) ๊ฐ’ f0, f1, f2, f3์— ๋Œ€ํ•ด ๋งค๊ฐœ๋ณ€์ˆ˜ f๋ฅผ ๊ฐ–๋Š” ์Šคํ”Œ๋ผ์ธ ๊ณก์„ ์„ ์–ป์Œ.
(public member function)
โš ๏ธ **GitHub.com Fallback** โš ๏ธ