math.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. /*
  2. * Copyright 2011-2022 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bx/blob/master/LICENSE
  4. */
  5. #ifndef BX_MATH_H_HEADER_GUARD
  6. #define BX_MATH_H_HEADER_GUARD
  7. #include "bx.h"
  8. #include "uint32_t.h"
  9. namespace bx
  10. {
  11. constexpr float kPi = 3.1415926535897932384626433832795f;
  12. constexpr float kPi2 = 6.2831853071795864769252867665590f;
  13. constexpr float kInvPi = 1.0f/kPi;
  14. constexpr float kPiHalf = 1.5707963267948966192313216916398f;
  15. constexpr float kPiQuarter = 0.7853981633974483096156608458199f;
  16. constexpr float kSqrt2 = 1.4142135623730950488016887242097f;
  17. constexpr float kLogNat10 = 2.3025850929940456840179914546844f;
  18. constexpr float kInvLogNat2 = 1.4426950408889634073599246810019f;
  19. constexpr float kLogNat2Hi = 0.6931471805599453094172321214582f;
  20. constexpr float kLogNat2Lo = 1.90821492927058770002e-10f;
  21. constexpr float kE = 2.7182818284590452353602874713527f;
  22. constexpr float kNearZero = 1.0f/float(1 << 28);
  23. constexpr float kFloatMin = 1.175494e-38f;
  24. constexpr float kFloatMax = 3.402823e+38f;
  25. extern const float kInfinity;
  26. ///
  27. typedef float (*LerpFn)(float _a, float _b, float _t);
  28. ///
  29. struct Handedness
  30. {
  31. enum Enum
  32. {
  33. Left,
  34. Right,
  35. };
  36. };
  37. ///
  38. struct NearFar
  39. {
  40. enum Enum
  41. {
  42. Default,
  43. Reverse,
  44. };
  45. };
  46. /// Structure initializer types.
  47. namespace init
  48. {
  49. /// Fields are left uninitialized.
  50. ///
  51. struct NoneType {};
  52. constexpr NoneType None;
  53. /// Fields are initialized to zero.
  54. ///
  55. struct ZeroType {};
  56. constexpr ZeroType Zero;
  57. /// Fields are initialized to identity value.
  58. ///
  59. struct IdentityType {};
  60. constexpr IdentityType Identity;
  61. }
  62. ///
  63. struct Vec3
  64. {
  65. Vec3() = delete;
  66. ///
  67. Vec3(init::NoneType);
  68. ///
  69. constexpr Vec3(init::ZeroType);
  70. ///
  71. constexpr Vec3(init::IdentityType);
  72. ///
  73. explicit constexpr Vec3(float _v);
  74. ///
  75. constexpr Vec3(float _x, float _y, float _z);
  76. float x, y, z;
  77. };
  78. ///
  79. struct Plane
  80. {
  81. Plane() = delete;
  82. ///
  83. Plane(init::NoneType);
  84. ///
  85. constexpr Plane(init::ZeroType);
  86. ///
  87. constexpr Plane(init::IdentityType);
  88. ///
  89. constexpr Plane(Vec3 _normal, float _dist);
  90. Vec3 normal;
  91. float dist;
  92. };
  93. ///
  94. struct Quaternion
  95. {
  96. Quaternion() = delete;
  97. ///
  98. Quaternion(init::NoneType);
  99. ///
  100. constexpr Quaternion(init::ZeroType);
  101. ///
  102. constexpr Quaternion(init::IdentityType);
  103. ///
  104. constexpr Quaternion(float _x, float _y, float _z, float _w);
  105. float x, y, z, w;
  106. };
  107. /// Returns converted the argument _deg to radians.
  108. ///
  109. BX_CONST_FUNC float toRad(float _deg);
  110. /// Returns converted the argument _rad to degrees.
  111. ///
  112. BX_CONST_FUNC float toDeg(float _rad);
  113. /// Reinterprets the bit pattern of _a as uint32_t.
  114. ///
  115. BX_CONST_FUNC uint32_t floatToBits(float _a);
  116. /// Reinterprets the bit pattern of _a as float.
  117. ///
  118. BX_CONST_FUNC float bitsToFloat(uint32_t _a);
  119. /// Reinterprets the bit pattern of _a as uint64_t.
  120. ///
  121. BX_CONST_FUNC uint64_t doubleToBits(double _a);
  122. /// Reinterprets the bit pattern of _a as double.
  123. ///
  124. BX_CONST_FUNC double bitsToDouble(uint64_t _a);
  125. /// Returns sortable floating point value.
  126. ///
  127. BX_CONST_FUNC uint32_t floatFlip(uint32_t _value);
  128. /// Returns true if _f is a number that is NaN.
  129. ///
  130. BX_CONST_FUNC bool isNan(float _f);
  131. /// Returns true if _f is a number that is NaN.
  132. ///
  133. BX_CONST_FUNC bool isNan(double _f);
  134. /// Returns true if _f is not infinite and is not a NaN.
  135. ///
  136. BX_CONST_FUNC bool isFinite(float _f);
  137. /// Returns true if _f is not infinite and is not a NaN.
  138. ///
  139. BX_CONST_FUNC bool isFinite(double _f);
  140. /// Returns true if _f is infinite and is not a NaN.
  141. ///
  142. BX_CONST_FUNC bool isInfinite(float _f);
  143. /// Returns true if _f is infinite and is not a NaN.
  144. ///
  145. BX_CONST_FUNC bool isInfinite(double _f);
  146. /// Returns the largest integer value not greater than _f.
  147. ///
  148. BX_CONSTEXPR_FUNC float floor(float _f);
  149. /// Returns the smallest integer value not less than _f.
  150. ///
  151. BX_CONSTEXPR_FUNC float ceil(float _f);
  152. /// Returns the nearest integer value to _f, rounding halfway cases away from zero,
  153. ///
  154. BX_CONSTEXPR_FUNC float round(float _f);
  155. /// Returns linear interpolation between two values _a and _b.
  156. ///
  157. BX_CONSTEXPR_FUNC float lerp(float _a, float _b, float _t);
  158. /// Returns inverse linear interpolation of _value between two values _a and _b.
  159. ///
  160. BX_CONSTEXPR_FUNC float invLerp(float _a, float _b, float _value);
  161. /// Returns the sign of _a.
  162. ///
  163. BX_CONSTEXPR_FUNC float sign(float _a);
  164. /// Returns the absolute of _a.
  165. ///
  166. BX_CONSTEXPR_FUNC float abs(float _a);
  167. /// Returns the square of _a.
  168. ///
  169. BX_CONSTEXPR_FUNC float square(float _a);
  170. /// Returns the cosine of the argument _a.
  171. ///
  172. BX_CONST_FUNC float sin(float _a);
  173. /// Returns hyperbolic sine of the argument _a.
  174. ///
  175. BX_CONST_FUNC float sinh(float _a);
  176. /// Returns radian angle between -pi/2 and +pi/2 whose sine is _a.
  177. ///
  178. BX_CONST_FUNC float asin(float _a);
  179. /// Returns the cosine of the argument _a.
  180. ///
  181. BX_CONST_FUNC float cos(float _a);
  182. /// Returns hyperbolic cosine of the argument _a.
  183. ///
  184. BX_CONST_FUNC float cosh(float _a);
  185. /// Returns radian angle between 0 and pi whose cosine is _a.
  186. ///
  187. BX_CONST_FUNC float acos(float _a);
  188. /// Returns the circular tangent of the radian argument _a.
  189. ///
  190. BX_CONST_FUNC float tan(float _a);
  191. /// Returns hyperbolic tangent of the argument _a.
  192. ///
  193. BX_CONST_FUNC float tanh(float _a);
  194. /// Returns radian angle between -pi/2 and +pi/2 whose tangent is _a.
  195. ///
  196. BX_CONST_FUNC float atan(float _a);
  197. /// Returns the inverse tangent of _y/_x.
  198. ///
  199. BX_CONST_FUNC float atan2(float _y, float _x);
  200. /// Computes _a raised to the _b power.
  201. ///
  202. BX_CONST_FUNC float pow(float _a, float _b);
  203. /// Returns the result of multiplying _a by 2 raised to the power of the exponent.
  204. ///
  205. BX_CONST_FUNC float ldexp(float _a, int32_t _b);
  206. /// Returns decomposed given floating point value _a into a normalized fraction and
  207. /// an integral power of two.
  208. ///
  209. float frexp(float _a, int32_t* _outExp);
  210. /// Returns e (2.71828...) raised to the _a power.
  211. ///
  212. BX_CONST_FUNC float exp(float _a);
  213. /// Returns 2 raised to the _a power.
  214. ///
  215. BX_CONST_FUNC float exp2(float _a);
  216. /// Returns the base e (2.71828...) logarithm of _a.
  217. ///
  218. BX_CONST_FUNC float log(float _a);
  219. /// Returns the base 2 logarithm of _a.
  220. ///
  221. template<typename Ty>
  222. BX_CONST_FUNC Ty log2(Ty _a);
  223. /// Returns the square root of _a.
  224. ///
  225. BX_CONST_FUNC float sqrt(float _a);
  226. /// Returns reciprocal square root of _a.
  227. ///
  228. BX_CONST_FUNC float rsqrt(float _a);
  229. /// Returns the nearest integer not greater in magnitude than _a.
  230. ///
  231. BX_CONSTEXPR_FUNC float trunc(float _a);
  232. /// Returns the fractional (or decimal) part of _a, which is greater than or equal to 0
  233. /// and less than 1.
  234. ///
  235. BX_CONSTEXPR_FUNC float fract(float _a);
  236. /// Returns result of negated multiply-sub operation -(_a * _b - _c) -> _c - _a * _b.
  237. ///
  238. BX_CONSTEXPR_FUNC float nms(float _a, float _b, float _c);
  239. /// Returns result of addition (_a + _b).
  240. ///
  241. BX_CONSTEXPR_FUNC float add(float _a, float _b);
  242. /// Returns result of subtracion (_a - _b).
  243. ///
  244. BX_CONSTEXPR_FUNC float sub(float _a, float _b);
  245. /// Returns result of multiply (_a * _b).
  246. ///
  247. BX_CONSTEXPR_FUNC float mul(float _a, float _b);
  248. /// Returns result of multiply and add (_a * _b + _c).
  249. ///
  250. BX_CONSTEXPR_FUNC float mad(float _a, float _b, float _c);
  251. /// Returns reciprocal of _a.
  252. ///
  253. BX_CONSTEXPR_FUNC float rcp(float _a);
  254. /// Returns the floating-point remainder of the division operation _a/_b.
  255. ///
  256. BX_CONST_FUNC float mod(float _a, float _b);
  257. ///
  258. BX_CONSTEXPR_FUNC bool isEqual(float _a, float _b, float _epsilon);
  259. ///
  260. BX_CONST_FUNC bool isEqual(const float* _a, const float* _b, uint32_t _num, float _epsilon);
  261. ///
  262. BX_CONST_FUNC float wrap(float _a, float _wrap);
  263. ///
  264. BX_CONSTEXPR_FUNC float step(float _edge, float _a);
  265. ///
  266. BX_CONSTEXPR_FUNC float pulse(float _a, float _start, float _end);
  267. ///
  268. BX_CONSTEXPR_FUNC float smoothStep(float _a);
  269. ///
  270. BX_CONST_FUNC float invSmoothStep(float _a);
  271. ///
  272. BX_CONSTEXPR_FUNC float bias(float _time, float _bias);
  273. ///
  274. BX_CONSTEXPR_FUNC float gain(float _time, float _gain);
  275. ///
  276. BX_CONST_FUNC float angleDiff(float _a, float _b);
  277. /// Returns shortest distance linear interpolation between two angles.
  278. ///
  279. BX_CONST_FUNC float angleLerp(float _a, float _b, float _t);
  280. ///
  281. template<typename Ty>
  282. Ty load(const void* _ptr);
  283. ///
  284. template<typename Ty>
  285. void store(void* _ptr, const Ty& _a);
  286. ///
  287. BX_CONSTEXPR_FUNC Vec3 round(const Vec3 _a);
  288. ///
  289. BX_CONSTEXPR_FUNC Vec3 abs(const Vec3 _a);
  290. ///
  291. BX_CONSTEXPR_FUNC Vec3 neg(const Vec3 _a);
  292. ///
  293. BX_CONSTEXPR_FUNC Vec3 add(const Vec3 _a, const Vec3 _b);
  294. ///
  295. BX_CONSTEXPR_FUNC Vec3 add(const Vec3 _a, float _b);
  296. ///
  297. BX_CONSTEXPR_FUNC Vec3 sub(const Vec3 _a, const Vec3 _b);
  298. ///
  299. BX_CONSTEXPR_FUNC Vec3 sub(const Vec3 _a, float _b);
  300. ///
  301. BX_CONSTEXPR_FUNC Vec3 mul(const Vec3 _a, const Vec3 _b);
  302. ///
  303. BX_CONSTEXPR_FUNC Vec3 mul(const Vec3 _a, float _b);
  304. ///
  305. BX_CONSTEXPR_FUNC Vec3 div(const Vec3 _a, const Vec3 _b);
  306. ///
  307. BX_CONSTEXPR_FUNC Vec3 div(const Vec3 _a, float _b);
  308. /// Returns result of negated multiply-sub operation -(_a * _b - _c) -> _c - _a * _b.
  309. ///
  310. BX_CONSTEXPR_FUNC Vec3 nms(const Vec3 _a, const float _b, const Vec3 _c);
  311. /// Returns result of negated multiply-sub operation -(_a * _b - _c) -> _c - _a * _b.
  312. ///
  313. BX_CONSTEXPR_FUNC Vec3 nms(const Vec3 _a, const Vec3 _b, const Vec3 _c);
  314. ///
  315. BX_CONSTEXPR_FUNC Vec3 mad(const Vec3 _a, const float _b, const Vec3 _c);
  316. ///
  317. BX_CONSTEXPR_FUNC Vec3 mad(const Vec3 _a, const Vec3 _b, const Vec3 _c);
  318. ///
  319. BX_CONSTEXPR_FUNC float dot(const Vec3 _a, const Vec3 _b);
  320. ///
  321. BX_CONSTEXPR_FUNC Vec3 cross(const Vec3 _a, const Vec3 _b);
  322. ///
  323. BX_CONST_FUNC float length(const Vec3 _a);
  324. ///
  325. BX_CONST_FUNC float distanceSq(const Vec3 _a, const Vec3 _b);
  326. ///
  327. BX_CONST_FUNC float distance(const Vec3 _a, const Vec3 _b);
  328. ///
  329. BX_CONSTEXPR_FUNC Vec3 lerp(const Vec3 _a, const Vec3 _b, float _t);
  330. ///
  331. BX_CONSTEXPR_FUNC Vec3 lerp(const Vec3 _a, const Vec3 _b, const Vec3 _t);
  332. ///
  333. BX_CONST_FUNC Vec3 normalize(const Vec3 _a);
  334. ///
  335. BX_CONSTEXPR_FUNC Vec3 min(const Vec3 _a, const Vec3 _b);
  336. ///
  337. BX_CONSTEXPR_FUNC Vec3 max(const Vec3 _a, const Vec3 _b);
  338. /// Returns component wise reciprocal of _a.
  339. ///
  340. BX_CONSTEXPR_FUNC Vec3 rcp(const Vec3 _a);
  341. ///
  342. BX_CONSTEXPR_FUNC bool isEqual(const Vec3 _a, const Vec3 _b, float _epsilon);
  343. ///
  344. void calcTangentFrame(Vec3& _outT, Vec3& _outB, const Vec3 _n);
  345. ///
  346. void calcTangentFrame(Vec3& _outT, Vec3& _outB, const Vec3 _n, float _angle);
  347. ///
  348. BX_CONST_FUNC Vec3 fromLatLong(float _u, float _v);
  349. ///
  350. void toLatLong(float* _outU, float* _outV, const Vec3 _dir);
  351. ///
  352. BX_CONSTEXPR_FUNC Quaternion invert(const Quaternion _a);
  353. ///
  354. BX_CONSTEXPR_FUNC Vec3 mulXyz(const Quaternion _a, const Quaternion _b);
  355. ///
  356. BX_CONSTEXPR_FUNC Quaternion add(const Quaternion _a, const Quaternion _b);
  357. ///
  358. BX_CONSTEXPR_FUNC Quaternion sub(const Quaternion _a, const Quaternion _b);
  359. ///
  360. BX_CONSTEXPR_FUNC Quaternion mul(const Quaternion _a, float _b);
  361. ///
  362. BX_CONSTEXPR_FUNC Quaternion mul(const Quaternion _a, const Quaternion _b);
  363. ///
  364. BX_CONSTEXPR_FUNC Vec3 mul(const Vec3 _v, const Quaternion _q);
  365. ///
  366. BX_CONSTEXPR_FUNC float dot(const Quaternion _a, const Quaternion _b);
  367. ///
  368. BX_CONSTEXPR_FUNC Quaternion normalize(const Quaternion _a);
  369. ///
  370. BX_CONSTEXPR_FUNC Quaternion lerp(const Quaternion _a, const Quaternion _b, float _t);
  371. ///
  372. BX_CONST_FUNC Quaternion fromEuler(const Vec3 _euler);
  373. ///
  374. BX_CONST_FUNC Vec3 toEuler(const Quaternion _a);
  375. ///
  376. BX_CONST_FUNC Vec3 toXAxis(const Quaternion _a);
  377. ///
  378. BX_CONST_FUNC Vec3 toYAxis(const Quaternion _a);
  379. ///
  380. BX_CONST_FUNC Vec3 toZAxis(const Quaternion _a);
  381. ///
  382. BX_CONST_FUNC Quaternion fromAxisAngle(const Vec3 _axis, float _angle);
  383. ///
  384. void toAxisAngle(Vec3& _outAxis, float& _outAngle, const Quaternion _a);
  385. ///
  386. BX_CONST_FUNC Quaternion rotateX(float _ax);
  387. ///
  388. BX_CONST_FUNC Quaternion rotateY(float _ay);
  389. ///
  390. BX_CONST_FUNC Quaternion rotateZ(float _az);
  391. ///
  392. BX_CONSTEXPR_FUNC bool isEqual(const Quaternion _a, const Quaternion _b, float _epsilon);
  393. ///
  394. void mtxIdentity(float* _result);
  395. ///
  396. void mtxTranslate(float* _result, float _tx, float _ty, float _tz);
  397. ///
  398. void mtxScale(float* _result, float _sx, float _sy, float _sz);
  399. ///
  400. void mtxScale(float* _result, float _scale);
  401. ///
  402. void mtxFromNormal(
  403. float* _result
  404. , const Vec3& _normal
  405. , float _scale
  406. , const Vec3& _pos
  407. );
  408. ///
  409. void mtxFromNormal(
  410. float* _result
  411. , const Vec3& _normal
  412. , float _scale
  413. , const Vec3& _pos
  414. , float _angle
  415. );
  416. ///
  417. void mtxFromQuaternion(float* _result, const Quaternion& _rotation);
  418. ///
  419. void mtxFromQuaternion(float* _result, const Quaternion& _rotation, const Vec3& _translation);
  420. ///
  421. void mtxLookAt(
  422. float* _result
  423. , const Vec3& _eye
  424. , const Vec3& _at
  425. , const Vec3& _up = { 0.0f, 1.0f, 0.0f }
  426. , Handedness::Enum _handedness = Handedness::Left
  427. );
  428. ///
  429. void mtxProj(
  430. float* _result
  431. , float _ut
  432. , float _dt
  433. , float _lt
  434. , float _rt
  435. , float _near
  436. , float _far
  437. , bool _homogeneousNdc
  438. , Handedness::Enum _handedness = Handedness::Left
  439. );
  440. ///
  441. void mtxProj(
  442. float* _result
  443. , const float _fov[4]
  444. , float _near
  445. , float _far
  446. , bool _homogeneousNdc
  447. , Handedness::Enum _handedness = Handedness::Left
  448. );
  449. ///
  450. void mtxProj(
  451. float* _result
  452. , float _fovy
  453. , float _aspect
  454. , float _near
  455. , float _far
  456. , bool _homogeneousNdc
  457. , Handedness::Enum _handedness = Handedness::Left
  458. );
  459. ///
  460. void mtxProjInf(
  461. float* _result
  462. , const float _fov[4]
  463. , float _near
  464. , bool _homogeneousNdc
  465. , Handedness::Enum _handedness = Handedness::Left
  466. , NearFar::Enum _nearFar = NearFar::Default
  467. );
  468. ///
  469. void mtxProjInf(
  470. float* _result
  471. , float _ut
  472. , float _dt
  473. , float _lt
  474. , float _rt
  475. , float _near
  476. , bool _homogeneousNdc
  477. , Handedness::Enum _handedness = Handedness::Left
  478. , NearFar::Enum _nearFar = NearFar::Default
  479. );
  480. ///
  481. void mtxProjInf(
  482. float* _result
  483. , float _fovy
  484. , float _aspect
  485. , float _near
  486. , bool _homogeneousNdc
  487. , Handedness::Enum _handedness = Handedness::Left
  488. , NearFar::Enum _nearFar = NearFar::Default
  489. );
  490. ///
  491. void mtxOrtho(
  492. float* _result
  493. , float _left
  494. , float _right
  495. , float _bottom
  496. , float _top
  497. , float _near
  498. , float _far
  499. , float _offset
  500. , bool _homogeneousNdc
  501. , Handedness::Enum _handedness = Handedness::Left
  502. );
  503. ///
  504. void mtxRotateX(float* _result, float _ax);
  505. ///
  506. void mtxRotateY(float* _result, float _ay);
  507. ///
  508. void mtxRotateZ(float* _result, float _az);
  509. ///
  510. void mtxRotateXY(float* _result, float _ax, float _ay);
  511. ///
  512. void mtxRotateXYZ(float* _result, float _ax, float _ay, float _az);
  513. ///
  514. void mtxRotateZYX(float* _result, float _ax, float _ay, float _az);
  515. ///
  516. void mtxSRT(
  517. float* _result
  518. , float _sx
  519. , float _sy
  520. , float _sz
  521. , float _ax
  522. , float _ay
  523. , float _az
  524. , float _tx
  525. , float _ty
  526. , float _tz
  527. );
  528. ///
  529. Vec3 mul(const Vec3& _vec, const float* _mat);
  530. ///
  531. Vec3 mulXyz0(const Vec3& _vec, const float* _mat);
  532. ///
  533. Vec3 mulH(const Vec3& _vec, const float* _mat);
  534. ///
  535. void vec4MulMtx(float* _result, const float* _vec, const float* _mat);
  536. ///
  537. void mtxMul(float* _result, const float* _a, const float* _b);
  538. ///
  539. void mtxTranspose(float* _result, const float* _a);
  540. ///
  541. void mtx3Inverse(float* _result, const float* _a);
  542. ///
  543. void mtxInverse(float* _result, const float* _a);
  544. ///
  545. void mtx3Cofactor(float* _result, const float* _a);
  546. ///
  547. void mtxCofactor(float* _result, const float* _a);
  548. ///
  549. Vec3 calcNormal(const Vec3& _va, const Vec3& _vb, const Vec3& _vc);
  550. ///
  551. void calcPlane(Plane& _outPlane, const Vec3& _va, const Vec3& _vb, const Vec3& _vc);
  552. ///
  553. void calcPlane(Plane& _outPlane, const Vec3& _normal, const Vec3& _pos);
  554. ///
  555. BX_CONSTEXPR_FUNC float distance(const Plane& _plane, const Vec3& _pos);
  556. ///
  557. BX_CONSTEXPR_FUNC bool isEqual(const Plane& _a, const Plane& _b, float _epsilon);
  558. ///
  559. void calcLinearFit2D(float _result[2], const void* _points, uint32_t _stride, uint32_t _numPoints);
  560. ///
  561. void calcLinearFit3D(float _result[3], const void* _points, uint32_t _stride, uint32_t _numPoints);
  562. ///
  563. void rgbToHsv(float _hsv[3], const float _rgb[3]);
  564. ///
  565. void hsvToRgb(float _rgb[3], const float _hsv[3]);
  566. ///
  567. BX_CONST_FUNC float toLinear(float _a);
  568. ///
  569. BX_CONST_FUNC float toGamma(float _a);
  570. } // namespace bx
  571. #include "inline/math.inl"
  572. #endif // BX_MATH_H_HEADER_GUARD