License Update
This commit is contained in:
parent
24eb70c5c9
commit
047348c585
37
gb_math.h
37
gb_math.h
|
@ -1,9 +1,10 @@
|
|||
// gb_math.h - v0.04c - public domain C math library - no warranty implied; use at your own risk
|
||||
// gb_math.h - v0.04d - public domain C math library - no warranty implied; use at your own risk
|
||||
// A C math library geared towards game development
|
||||
// use '#define GB_MATH_IMPLEMENTATION' before including to create the implementation in _ONE_ file
|
||||
|
||||
/*
|
||||
Version History:
|
||||
0.04d - License Update
|
||||
0.04c - Use 64-bit murmur64 version on WIN64
|
||||
0.04b - Fix strict aliasing in gb_quake_inv_sqrt
|
||||
0.04a - Minor bug fixes
|
||||
|
@ -12,10 +13,9 @@ Version History:
|
|||
0.01 - Initial Version
|
||||
|
||||
LICENSE
|
||||
This software is in the public domain. Where that dedication is not
|
||||
recognized, you are granted a perpetual, irrevocable license to copy,
|
||||
distribute, and modify this file as you see fit.
|
||||
|
||||
This software is dual-licensed to the public domain and under the following
|
||||
license: you are granted a perpetual, irrevocable license to copy, modify,
|
||||
publish, and distribute this file as you see fit.
|
||||
WARNING
|
||||
- This library is _slightly_ experimental and features may not work as expected.
|
||||
- This also means that many functions are not documented.
|
||||
|
@ -45,6 +45,7 @@ CONTENTS
|
|||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
#include <string.h> // memcpy, memmove, etc.
|
||||
|
||||
#ifndef GB_MATH_DEF
|
||||
#ifdef GB_MATH_STATIC
|
||||
|
@ -171,8 +172,12 @@ GB_MATH_DEF float gb_to_degrees(float radians);
|
|||
// NOTE(bill): Because to interpolate angles
|
||||
GB_MATH_DEF float gb_angle_diff(float radians_a, float radians_b);
|
||||
|
||||
#ifndef gb_min
|
||||
#define gb_min(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef gb_max
|
||||
#define gb_max(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
GB_MATH_DEF float gb_sqrt(float a);
|
||||
GB_MATH_DEF float gb_quake_inv_sqrt(float a); // NOTE(bill): It's probably better to use 1.0f/gb_sqrt(a)
|
||||
|
@ -775,12 +780,12 @@ float
|
|||
gb_half_to_float(gb_half value)
|
||||
{
|
||||
gb_uif32 result;
|
||||
int s = (value >> 15) & 0x00000001;
|
||||
int e = (value >> 10) & 0x0000001f;
|
||||
int m = value & 0x000003ff;
|
||||
int s = (value >> 15) & 0x001;
|
||||
int e = (value >> 10) & 0x01f;
|
||||
int m = value & 0x3ff;
|
||||
|
||||
if (e == 0) {
|
||||
if(m == 0) {
|
||||
if (m == 0) {
|
||||
// Plus or minus zero
|
||||
result.i = (unsigned int)(s << 31);
|
||||
return result.f;
|
||||
|
@ -1072,13 +1077,7 @@ gb_vec3_refract(gbVec3 *d, gbVec3 i, gbVec3 n, float eta)
|
|||
|
||||
|
||||
|
||||
float
|
||||
gb_vec2_aspect_ratio(gbVec2 v)
|
||||
{
|
||||
if (v.y < 0.0001f)
|
||||
return 0.0f;
|
||||
return v.x/v.y;
|
||||
}
|
||||
float gb_vec2_aspect_ratio(gbVec2 v) { return (v.y < 0.0001f) ? 0.0f : v.x/v.y; }
|
||||
|
||||
|
||||
|
||||
|
@ -1095,11 +1094,7 @@ gb_float22_identity(float m[2][2])
|
|||
m[1][0] = 0; m[1][1] = 1;
|
||||
}
|
||||
|
||||
void
|
||||
gb_mat2_mul_vec2(gbVec2 *out, gbMat2 *m, gbVec2 in)
|
||||
{
|
||||
gb_float22_mul_vec2(out, gb_float22_m(m), in);
|
||||
}
|
||||
void gb_mat2_mul_vec2(gbVec2 *out, gbMat2 *m, gbVec2 in) { gb_float22_mul_vec2(out, gb_float22_m(m), in); }
|
||||
|
||||
gbMat2 *gb_mat2_v(gbVec2 m[2]) { return (gbMat2 *)m; }
|
||||
gbMat2 *gb_mat2_f(float m[2][2]) { return (gbMat2 *)m; }
|
||||
|
|
Loading…
Reference in New Issue