summaryrefslogtreecommitdiff
path: root/src/glm/affine3d.c
blob: c392d0374abf7c8e87054936aa8613056eaaf75c (plain)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#include <lua.h>
#include <lauxlib.h>
#include <cglm/cglm.h>
#include "glm.h"


int glm_uniscaled_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	bool bind_result = glm_uniscaled(*m);
	lua_pushboolean(L, bind_result);
	return 1;
}


int glm_decompose_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	vec4 *t = luaL_checkudata(L, 2, glm_vec4_tname);
	mat4 *r = luaL_checkudata(L, 3, glm_mat4_tname);
	vec3 *s = luaL_checkudata(L, 4, glm_vec3_tname);
	glm_decompose(*m, *t, *r, *s);
	return 0;
}


int glm_decompose_rs_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	mat4 *r = luaL_checkudata(L, 2, glm_mat4_tname);
	vec3 *s = luaL_checkudata(L, 3, glm_vec3_tname);
	glm_decompose_rs(*m, *r, *s);
	return 0;
}


int glm_decompose_scalev_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	vec3 *s = luaL_checkudata(L, 2, glm_vec3_tname);
	glm_decompose_scalev(*m, *s);
	return 0;
}


int glm_rotate_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	float angle = luaL_checknumber(L, 2);
	vec3 *axis = luaL_checkudata(L, 3, glm_vec3_tname);
	glm_rotate(*m, angle, *axis);
	return 0;
}


int glm_rotate_at_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	vec3 *pivot = luaL_checkudata(L, 2, glm_vec3_tname);
	float angle = luaL_checknumber(L, 3);
	vec3 *axis = luaL_checkudata(L, 4, glm_vec3_tname);
	glm_rotate_at(*m, *pivot, angle, *axis);
	return 0;
}


int glm_rotate_atm_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	vec3 *pivot = luaL_checkudata(L, 2, glm_vec3_tname);
	float angle = luaL_checknumber(L, 3);
	vec3 *axis = luaL_checkudata(L, 4, glm_vec3_tname);
	glm_rotate_atm(*m, *pivot, angle, *axis);
	return 0;
}


int glm_rotate_make_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	float angle = luaL_checknumber(L, 2);
	vec3 *axis = luaL_checkudata(L, 3, glm_vec3_tname);
	glm_rotate_make(*m, angle, *axis);
	return 0;
}


int glm_rotate_x_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	float angle = luaL_checknumber(L, 2);
	mat4 *dest = luaL_checkudata(L, 3, glm_mat4_tname);
	glm_rotate_x(*m, angle, *dest);
	return 0;
}


int glm_rotate_y_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	float angle = luaL_checknumber(L, 2);
	mat4 *dest = luaL_checkudata(L, 3, glm_mat4_tname);
	glm_rotate_y(*m, angle, *dest);
	return 0;
}


int glm_rotate_z_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	float angle = luaL_checknumber(L, 2);
	mat4 *dest = luaL_checkudata(L, 3, glm_mat4_tname);
	glm_rotate_z(*m, angle, *dest);
	return 0;
}


int glm_scale_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	vec3 *v = luaL_checkudata(L, 2, glm_vec3_tname);
	glm_scale(*m, *v);
	return 0;
}


int glm_scale_make_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	vec3 *v = luaL_checkudata(L, 2, glm_vec3_tname);
	glm_scale_make(*m, *v);
	return 0;
}


int glm_scale_to_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	vec3 *v = luaL_checkudata(L, 2, glm_vec3_tname);
	mat4 *dest = luaL_checkudata(L, 3, glm_mat4_tname);
	glm_scale_to(*m, *v, *dest);
	return 0;
}


int glm_scale_uni_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	float s = luaL_checknumber(L, 2);
	glm_scale_uni(*m, s);
	return 0;
}


int glm_translate_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	vec3 *v = luaL_checkudata(L, 2, glm_vec3_tname);
	glm_translate(*m, *v);
	return 0;
}


int glm_translate_make_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	vec3 *v = luaL_checkudata(L, 2, glm_vec3_tname);
	glm_translate_make(*m, *v);
	return 0;
}


int glm_translate_to_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	vec3 *v = luaL_checkudata(L, 2, glm_vec3_tname);
	mat4 *dest = luaL_checkudata(L, 3, glm_mat4_tname);
	glm_translate_to(*m, *v, *dest);
	return 0;
}


int glm_translate_x_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	float x = luaL_checknumber(L, 2);
	glm_translate_x(*m, x);
	return 0;
}


int glm_translate_y_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	float y = luaL_checknumber(L, 2);
	glm_translate_y(*m, y);
	return 0;
}


int glm_translate_z_bind(lua_State *L)
{
	mat4 *m = luaL_checkudata(L, 1, glm_mat4_tname);
	float z = luaL_checknumber(L, 2);
	glm_translate_z(*m, z);
	return 0;
}