Skip to content

Commit

Permalink
Merge pull request #1 from littlstar/whitespace-reorg
Browse files Browse the repository at this point in the history
Whitespace reorg
  • Loading branch information
jwerle committed Feb 7, 2016
2 parents 220d811 + 6fbcef3 commit 7b6fa8b
Show file tree
Hide file tree
Showing 15 changed files with 191 additions and 185 deletions.
1 change: 1 addition & 0 deletions include/glisy/camera/perspective.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ struct glisy_perspective_camera {

double far;
};

#endif
1 change: 1 addition & 0 deletions include/glisy/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct glisy_context {
*/

void *data;

};

/**
Expand Down
1 change: 1 addition & 0 deletions include/glisy/glisy.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ glisy_render (const glisy_renderer,
#ifdef __cplusplus
}
#endif

#endif
1 change: 0 additions & 1 deletion include/glisy/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@
#include <glisy/math/mat4.h>
#include <glisy/math/quat.h>


#endif
99 changes: 50 additions & 49 deletions include/glisy/math/mat2.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,55 +12,55 @@ struct mat2 {
};

/**
* mat2 initializer.
* mat2 initializers.
*/

#define mat2(m11, m12, m21, m22) ((mat2) {m11, m12, m21, m22})
#define mat2_create() mat2(1, 0, 0, 1)
#define mat2_create() mat2(1, 0, \
0, 1)

#define mat2(m11, m12, m21, m22) ((mat2) {m11, m12, \
m21, m22})

/**
* Clones and returns mat2 a.
*/

#define mat2_clone(a) (mat2) {a.m11, a.m12, a.m21, a.m22}
#define mat2_clone(a) ((mat2) {a.m11, a.m12, \
a.m21, a.m22})

/**
* Copies mat2 b into mat2 a.
*/

#define mat2_copy(a, b) (mat2) ({ \
mat2 *tmp = &a; \
(tmp->m11 = b.m11); \
(tmp->m12 = b.m12); \
(tmp->m21 = b.m21); \
(tmp->m22 = b.m22); \
(*tmp); \
#define mat2_copy(a, b) (mat2) ({ \
mat2 *tmp = &a; \
(tmp->m11 = b.m11), (tmp->m12 = b.m12); \
(tmp->m21 = b.m21), (tmp->m22 = b.m22); \
(*tmp); \
})

/**
* Sets an identity for mat2 a.
*/

#define mat2_identity(a) (mat2) ({ \
mat2 *tmp = &a; \
(tmp->m11 = 1); \
(tmp->m12 = 0); \
(tmp->m21 = 0); \
(tmp->m22 = 1); \
(*tmp); \
#define mat2_identity(a) (mat2) ({ \
mat2 *tmp = &a; \
(tmp->m11 = 1), (tmp->m12 = 0); \
(tmp->m21 = 0), (tmp->m22 = 1); \
(*tmp); \
})

/**
* Transposes mat2 a.
*/

#define mat2_transpose(a) (mat2) ({ \
mat2(a.m11, a.m21, a.m12, a.m22); \
#define mat2_transpose(a) (mat2) ({ \
mat2(a.m11, a.m21, \
a.m12, a.m22); \
})

/**
* Calculates and sets inverse for
* mat2 a.
* Calculates and returns inverse for mat2 a.
*/

#define mat2_invert(a) (mat2) ({ \
Expand Down Expand Up @@ -100,7 +100,25 @@ struct mat2 {
})

/**
* Returns the product of mat2 a and mat2 b.
* Add mat2 a and mat2 b.
*/

#define mat2_add(a, b) ((mat2) { \
a.m11 + b.m11, a.m12 + b.m12, \
a.m21 + b.m21, b.m22 + b.m22 \
})

/**
* Subtract mat2 b from mat2 a.
*/

#define mat2_subtract(a, b) ((mat2) { \
a.m11 - b.m11, a.m12 - b.m12, \
a.m21 - b.m21, b.m22 - b.m22 \
})

/**
* Multiply mat2 a and mat2 b.
*/

#define mat2_multiply(a, b) ((mat2) { \
Expand All @@ -124,21 +142,21 @@ struct mat2 {
}))

/**
* Scale mat2 a by vec2 b.
* Creates a mat2 from rotation rad.
*/

#define mat2_scale(a, b) ((mat2) { \
(a.m11 * b.x), (a.m12 * b.x), \
(a.m21 * b.y), (a.m22 * b.y) \
#define mat2_from_rotation(rad) ((mat2) { \
cosf(rad), sinf(rad), \
-sinf(rad), cosf(rad) \
})

/**
* Creates a mat2 from rotation rad.
* Scale mat2 a by vec2 b.
*/

#define mat2_from_rotation(rad) ((mat2) { \
cosf(rad), sinf(rad), \
-sinf(rad), cosf(rad) \
#define mat2_scale(a, b) ((mat2) { \
(a.m11 * b.x), (a.m12 * b.x), \
(a.m21 * b.y), (a.m22 * b.y) \
})

/**
Expand All @@ -159,24 +177,6 @@ struct mat2 {
powf(a.m22, 2.0) \
)

/**
* Adds mat2 a and mat2 b.
*/

#define mat2_add(a, b) ((mat2) { \
a.m11 + b.m11, a.m12 + b.m12, \
a.m21 + b.m21, b.m22 + b.m22 \
})

/**
* Subtract mat2 b from mat2 a.
*/

#define mat2_subtract(a, b) ((mat2) { \
a.m11 - b.m11, a.m12 - b.m12, \
a.m21 - b.m21, b.m22 - b.m22 \
})

/**
* Returns a string representation of mat2 a.
*/
Expand All @@ -188,4 +188,5 @@ struct mat2 {
a.m11, a.m12, a.m21, a.m22); \
(strdup(str)); \
})

#endif
115 changes: 58 additions & 57 deletions include/glisy/math/mat3.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ struct mat3 {
};

/**
* mat3 initializer.
* mat3 initializers.
*/

#define mat3_create() mat3(1,0,0, \
0,1,0, \
0,0,1)

#define mat3(m11, m12, m13, \
m21, m22, m23, \
m31, m32, m33) ((mat3) {m11, m12, m13, \
Expand Down Expand Up @@ -61,15 +62,14 @@ struct mat3 {
* Transposes mat3 a.
*/

#define mat3_transpose(a) (mat3) ({ \
mat3(a.m11, a.m21, a.m31, \
a.m12, a.m22, a.m32, \
a.m13, a.m23, a.m33); \
#define mat3_transpose(a) (mat3) ({ \
mat3(a.m11, a.m21, a.m31, \
a.m12, a.m22, a.m32, \
a.m13, a.m23, a.m33); \
})

/**
* Calculates and returns inverse for
* mat3 a.
* Calculates and returns inverse for mat3 a.
*/

#define mat3_invert(a) (mat3) ({ \
Expand Down Expand Up @@ -128,7 +128,27 @@ struct mat3 {
})

/**
* Returns the product of mat3 a and mat3 b.
* Add mat3 a and mat3 b.
*/

#define mat3_add(a, b) ((mat3) { \
a.m11 + b.m11, a.m12 + b.m12, a.m13 + b.m13, \
a.m21 + b.m21, b.m22 + b.m22, a.m23 + b.m23, \
a.m31 + b.m31, b.m32 + b.m32, a.m33 + b.m33 \
})

/**
* Subtract mat3 b from mat3 a.
*/

#define mat3_subtract(a, b) ((mat3) { \
a.m11 - b.m11, a.m12 - b.m12, a.m13 - b.m13, \
a.m21 - b.m21, b.m22 - b.m22, a.m23 - b.m23, \
a.m31 - b.m31, b.m32 - b.m32, a.m33 - b.m33 \
})

/**
* multiply mat3 a and mat3 b.
*/

#define mat3_multiply(a, b) ((mat3) mat3( \
Expand All @@ -145,18 +165,6 @@ struct mat3 {
(a.m13 * b.m31 + a.m23 * b.m32 + a.m33 * b.m33) \
))

/**
* Translate mat3 a by vec2 b.
*/

#define mat3_translate(a, b) ((mat3) mat3( \
a.m11, a.m12, a.m13, \
a.m21, a.m22, a.m23, \
(b.x * a.m11 + b.y * a.m21 + a.m31), \
(b.x * a.m12 + b.y * a.m22 + a.m32), \
(b.x * a.m13 + b.y * a.m23 + a.m33) \
))

/**
* Rotates mat3 a by angle rad.
*/
Expand All @@ -174,6 +182,16 @@ struct mat3 {
); \
}))

/**
* Creates mat3 from rotation angle rad.
*/

#define mat3_from_rotation(rad) ((mat3) { \
cosf(rad), sinf(rad), 0, \
-sinf(rad), cosf(rad), 0, \
0, 0, 1 \
})

/**
* Scales mat3 a by vec2 b.
*/
Expand All @@ -185,35 +203,37 @@ struct mat3 {
})

/**
* Creates mat3 from translation vec2 a.
* Creates mat3 from scale vec2 a.
*/

#define mat3_from_translation(a) ((mat3) {1, 0, 0, \
0, 1, 0, \
a.x, a.y, 1})
#define mat3_from_scale(a) ((mat3) { \
a.x, 0, 0, \
0, a.y, 0, \
0, 0, 1 \
})

/**
* Creates mat3 from rotation angle rad.
* Translate mat3 a by vec2 b.
*/

#define mat3_from_rotation(rad) ((mat3) { \
cosf(rad), sinf(rad), 0, \
-sinf(rad), cosf(rad), 0, \
0, 0, 1 \
})
#define mat3_translate(a, b) ((mat3) mat3( \
a.m11, a.m12, a.m13, \
a.m21, a.m22, a.m23, \
(b.x * a.m11 + b.y * a.m21 + a.m31), \
(b.x * a.m12 + b.y * a.m22 + a.m32), \
(b.x * a.m13 + b.y * a.m23 + a.m33) \
))

/**
* Creates mat3 from scale vec2 a.
* Creates mat3 from translation vec2 a.
*/

#define mat3_from_scale(a) ((mat3) { \
a.x, 0, 0, \
0, a.y, 0, \
0, 0, 1 \
})
#define mat3_from_translation(a) ((mat3) {1, 0, 0, \
0, 1, 0, \
a.x, a.y, 1})

/**
* Creates mat2 from quat a.
* Creates mat3 from quat a.
*/

#define mat3_from_quat(a) ((mat3) ({ \
Expand Down Expand Up @@ -241,26 +261,6 @@ struct mat3 {
(1 - xx - yy)); \
}))

/**
* Adds mat3 a and mat3 b.
*/

#define mat3_add(a, b) ((mat3) { \
a.m11 + b.m11, a.m12 + b.m12, a.m13 + b.m13, \
a.m21 + b.m21, b.m22 + b.m22, a.m23 + b.m23, \
a.m31 + b.m31, b.m32 + b.m32, a.m33 + b.m33 \
})

/**
* Subtract mat3 b from mat3 a.
*/

#define mat3_subtract(a, b) ((mat3) { \
a.m11 - b.m11, a.m12 - b.m12, a.m13 - b.m13, \
a.m21 - b.m21, b.m22 - b.m22, a.m23 - b.m23, \
a.m31 - b.m31, b.m32 - b.m32, a.m33 - b.m33 \
})

/**
* Calculates Frobenius norm mat3 a.
*/
Expand Down Expand Up @@ -292,4 +292,5 @@ struct mat3 {
b.m31, b.m32, b.m33); \
(strdup(str)); \
})

#endif
Loading

0 comments on commit 7b6fa8b

Please sign in to comment.