-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinalg.h
More file actions
89 lines (75 loc) · 1.33 KB
/
linalg.h
File metadata and controls
89 lines (75 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef _CLOTHSIM_LINALG_H
#define _CLOTHSIM_LINALG_H
typedef struct Vec2f
{
union
{
struct
{
float x;
float y;
};
float raw[2];
};
} Vec2f;
typedef struct Vec3f
{
union
{
struct
{
float x;
float y;
float z;
};
float raw[3];
};
} Vec3f;
typedef struct Vec4f
{
union
{
struct
{
float x;
float y;
float z;
float w;
};
float raw[4];
};
} Vec4f;
typedef struct Vec2i
{
union
{
struct
{
int x;
int y;
};
int raw[2];
};
} Vec2i;
typedef struct Mat4f
{
union
{
struct
{
Vec4f x;
Vec4f y;
Vec4f z;
Vec4f w;
};
float raw[16];
} ;
} Mat4f;
#define v2f(X,Y) ((Vec2f) {.x = X, .y = Y})
#define v3f(X,Y,Z) ((Vec3f) {.x = X, .y = Y, .z = Z})
#define v4f(X,Y,Z,W) ((Vec4f) {.x = X, .y = Y, .z = Z, .w = W})
#define v2i(X,Y) ((Vec2i){.x = X, .y = Y})
#define mat4f(X,Y,Z,W) ((Mat4f) {.x = X, .y = Y, .z = Z, .w = W})
Mat4f orthographic(float, float, float, float, float, float);
Mat4f perspective(float, float, float, float, float);
#endif //_CLOTHSIM_LINALG_H