#ifndef CODUO_SHARED_Q_MATH_H
#define CODUO_SHARED_Q_MATH_H

#include <stdint.h>

#include "q_collision_types.h"

#ifdef __cplusplus
extern "C" {
#endif

#define NUMVERTEXNORMALS 162

extern vec3_t bytedirs[NUMVERTEXNORMALS];

int32_t Q_log2(int32_t value);
int8_t ClampChar(int32_t value);
int16_t ClampShort(int32_t value);
uint8_t DirToByte(const vec3_t direction);
void ByteToDir(int32_t value, vec3_t direction);
void SetPlaneSignbits(cplane_t *plane);
void _VectorSubtract(const vec3_t first, const vec3_t second, vec3_t result);
void _VectorAdd(const vec3_t first, const vec3_t second, vec3_t result);
void _VectorCopy(const vec3_t source, vec3_t destination);
void _VectorScale(const vec3_t vector, float scale, vec3_t result);
void _VectorMA(const vec3_t start, float scale, const vec3_t direction,
               vec3_t result);
void VectorInverse(vec3_t vector);
void Vector4Scale(const vec4_t input, float scale, vec4_t output);
void ClearBounds(vec3_t mins, vec3_t maxs);
void AddPointToBounds(const vec3_t point, vec3_t mins, vec3_t maxs);
void ExpandBounds(const vec3_t addMins, const vec3_t addMaxs,
                  vec3_t mins, vec3_t maxs);
void AxisClear(axis_t axis);
void AxisCopy(const axis_t input, axis_t output);
void MatrixTranspose(const axis_t input, axis_t output);
void PerpendicularVector2D(const vec2_t input, vec3_t output);
void QuatInverse(const vec4_t input, vec4_t output);

#ifdef __cplusplus
}
#endif

#endif
