Space Sim
Loading...
Searching...
No Matches
mathf.h File Reference
#include <math.h>
#include "core/types.h"

Go to the source code of this file.

Macros

#define MAX(a, b)
#define MIN(a, b)

Functions

vec3 vec3_normalize (vec3 v)
vec3 ivec3_normalize (ivec3 a)
vec3 vec3_cross (vec3 a, vec3 b)
vec2 vec2_scale (vec2 a, float b)
vec3 vec3_scale (vec3 a, float b)
vec4 vec4_scale (vec4 a, float b)
float ivec3_dist (ivec3 a, ivec3 b)
ivec3 ivec3_sub (ivec3 a, ivec3 b)
vec3 vec3_sub (vec3 a, vec3 b)
vec2 vec2_add (vec2 a, vec2 b)
ivec3 ivec3_add (ivec3 a, ivec3 b)
vec3 ivec3_scale (ivec3 a, float b)
vec3 vec3_add (vec3 a, vec3 b)
vec4 vec4_add (vec4 a, vec4 b)
vec4 vec4_sub (vec4 a, vec4 b)
vec3 vec3_mul (vec3 a, vec3 b)
vec4 vec4_mul (vec4 a, vec4 b)
float vec3_dist2 (vec3 a, vec3 b)
float vec3_dist (vec3 a, vec3 b)
float vec3_dot (vec3 a, vec3 b)
float vec2_dot (vec2 a, vec2 b)
float vec3_length (vec3 v)
mat4 mat4_inverse (mat4 in)
float lerp (float a, float b, float t)
float clamp (float a, float b, float c)
vec4 mul_m4_v4 (mat4 m, vec4 v)
mat4 m4_mul (mat4 a, mat4 b)
void mat4_mul (float out[16], const float a[16], const float b[16])
uint32_t expand_bits (uint32_t v)
uint32_t morton (uint32_t x, uint32_t y, uint32_t z)

Macro Definition Documentation

◆ MAX

#define MAX ( a,
b )
Value:
(a > b ? (a) : (b))

Definition at line 191 of file mathf.h.

Referenced by load_chunks().

◆ MIN

#define MIN ( a,
b )
Value:
(a < b ? (a) : (b))

Definition at line 193 of file mathf.h.

Referenced by load_chunks(), and worley().

Function Documentation

◆ vec3_normalize()

◆ ivec3_normalize()

vec3 ivec3_normalize ( ivec3 a)
inline

Definition at line 16 of file mathf.h.

References ivec3_normalize(), ivec3::x, vec3::x, ivec3::y, vec3::y, ivec3::z, and vec3::z.

Referenced by ivec3_normalize().

◆ vec3_cross()

vec3 vec3_cross ( vec3 a,
vec3 b )
inline

Definition at line 27 of file mathf.h.

References vec3_cross(), vec3::x, vec3::y, and vec3::z.

Referenced by compute_camera_basis(), init_random(), mat4_inverse(), signed_angle_3d(), and vec3_cross().

◆ vec2_scale()

vec2 vec2_scale ( vec2 a,
float b )
inline

Definition at line 35 of file mathf.h.

References vec2_scale(), vec2::x, and vec2::y.

Referenced by fbm_noise(), and vec2_scale().

◆ vec3_scale()

◆ vec4_scale()

vec4 vec4_scale ( vec4 a,
float b )
inline

Definition at line 43 of file mathf.h.

References vec4_scale(), vec4::w, vec4::x, vec4::y, and vec4::z.

Referenced by apply_planet_velocity(), apply_velocity(), fbm_noise(), perm(), and vec4_scale().

◆ ivec3_dist()

float ivec3_dist ( ivec3 a,
ivec3 b )
inline

Definition at line 48 of file mathf.h.

References ivec3_dist(), ivec3::x, ivec3::y, and ivec3::z.

Referenced by ivec3_dist(), and load_chunks().

◆ ivec3_sub()

ivec3 ivec3_sub ( ivec3 a,
ivec3 b )
inline

Definition at line 53 of file mathf.h.

References ivec3_sub(), ivec3::x, ivec3::y, and ivec3::z.

Referenced by ivec3_sub().

◆ vec3_sub()

vec3 vec3_sub ( vec3 a,
vec3 b )
inline

◆ vec2_add()

vec2 vec2_add ( vec2 a,
vec2 b )
inline

Definition at line 61 of file mathf.h.

References vec2_add(), vec2::x, and vec2::y.

Referenced by fbm_noise(), and vec2_add().

◆ ivec3_add()

ivec3 ivec3_add ( ivec3 a,
ivec3 b )
inline

Definition at line 65 of file mathf.h.

References ivec3_add(), ivec3::x, ivec3::y, and ivec3::z.

Referenced by ivec3_add(), and load_chunks().

◆ ivec3_scale()

vec3 ivec3_scale ( ivec3 a,
float b )
inline

Definition at line 69 of file mathf.h.

References ivec3_scale(), ivec3::x, ivec3::y, and ivec3::z.

Referenced by ivec3_scale(), and load_chunks().

◆ vec3_add()

◆ vec4_add()

vec4 vec4_add ( vec4 a,
vec4 b )
inline

Definition at line 77 of file mathf.h.

References vec4_add(), vec4::w, vec4::x, vec4::y, and vec4::z.

Referenced by fbm_noise(), get_view_planes(), perm(), and vec4_add().

◆ vec4_sub()

vec4 vec4_sub ( vec4 a,
vec4 b )
inline

Definition at line 81 of file mathf.h.

References vec4_sub(), vec4::w, vec4::x, vec4::y, and vec4::z.

Referenced by get_view_planes(), and vec4_sub().

◆ vec3_mul()

vec3 vec3_mul ( vec3 a,
vec3 b )
inline

Definition at line 85 of file mathf.h.

References vec3_mul(), vec3::x, vec3::y, and vec3::z.

Referenced by fbm_noise(), and vec3_mul().

◆ vec4_mul()

vec4 vec4_mul ( vec4 a,
vec4 b )
inline

Definition at line 89 of file mathf.h.

References vec4_mul(), vec4::w, vec4::x, vec4::y, and vec4::z.

Referenced by perm(), and vec4_mul().

◆ vec3_dist2()

float vec3_dist2 ( vec3 a,
vec3 b )
inline

Definition at line 93 of file mathf.h.

References vec3_dist2(), vec3_sub(), vec3::x, vec3::y, and vec3::z.

Referenced by vec3_dist2().

◆ vec3_dist()

float vec3_dist ( vec3 a,
vec3 b )
inline

Definition at line 97 of file mathf.h.

References vec3_dist(), vec3_sub(), vec3::x, vec3::y, and vec3::z.

Referenced by vec3_dist().

◆ vec3_dot()

float vec3_dot ( vec3 a,
vec3 b )
inline

◆ vec2_dot()

float vec2_dot ( vec2 a,
vec2 b )
inline

Definition at line 104 of file mathf.h.

References vec2_dot(), vec2::x, and vec2::y.

Referenced by init_water_grid(), and vec2_dot().

◆ vec3_length()

float vec3_length ( vec3 v)
inline

Definition at line 107 of file mathf.h.

References vec3_length(), vec3::x, vec3::y, and vec3::z.

Referenced by find_surface_entry(), vec3_length(), and worley().

◆ mat4_inverse()

◆ lerp()

float lerp ( float a,
float b,
float t )
inline

Definition at line 143 of file mathf.h.

References lerp(), and t.

Referenced by apply_planet_velocity(), apply_velocity(), lerp(), sample_density(), and sample_fbm_density().

◆ clamp()

float clamp ( float a,
float b,
float c )
inline

Definition at line 147 of file mathf.h.

References clamp().

Referenced by apply_air_acceleration(), clamp(), main(), and unpack_normal().

◆ mul_m4_v4()

vec4 mul_m4_v4 ( mat4 m,
vec4 v )
inline

◆ m4_mul()

◆ mat4_mul()

void mat4_mul ( float out[16],
const float a[16],
const float b[16] )
inline

Definition at line 179 of file mathf.h.

References mat4_mul().

Referenced by mat4_mul().

◆ expand_bits()

uint32_t expand_bits ( uint32_t v)
inline

Definition at line 196 of file mathf.h.

References expand_bits().

◆ morton()

uint32_t morton ( uint32_t x,
uint32_t y,
uint32_t z )
inline

Definition at line 205 of file mathf.h.

References expand_bits(), and morton().