First commit
This commit is contained in:
commit
546648cbdd
4 changed files with 244 additions and 0 deletions
60
hex_math.h
Normal file
60
hex_math.h
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
/* Types */
|
||||
typedef float _v2f __attribute__((matrix_type(1,2)));
|
||||
typedef float _v3f __attribute__((matrix_type(1,3)));
|
||||
typedef float _v4f __attribute__((matrix_type(1,4)));
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
float first;
|
||||
_v3f tail;
|
||||
};
|
||||
struct {
|
||||
_v2f first_half;
|
||||
_v2f second_half;
|
||||
};
|
||||
struct {
|
||||
_v3f v3f;
|
||||
float last;
|
||||
};
|
||||
_v4f v4f;
|
||||
struct {
|
||||
float r;
|
||||
float g;
|
||||
float b;
|
||||
float a;
|
||||
};
|
||||
struct {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float w;
|
||||
};
|
||||
};
|
||||
} vec4f;
|
||||
|
||||
typedef struct {
|
||||
vec4f position; // center pos
|
||||
float radius; // side length
|
||||
} hex_t;
|
||||
|
||||
typedef struct {
|
||||
hex_t *hexes;
|
||||
uint32_t rows;
|
||||
uint32_t columns;
|
||||
} hexgrid_t;
|
||||
|
||||
_Static_assert(sizeof(vec4f) == sizeof(float) * 4, "Bad vector size");
|
||||
|
||||
/* Functions */
|
||||
double sint(double turns)
|
||||
{
|
||||
return sin(turns*2*M_PI);
|
||||
}
|
||||
|
||||
double cost(double turns)
|
||||
{
|
||||
return cos(turns*2*M_PI);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue