diff options
author | Adam NAILI | 2017-12-27 17:19:23 +0100 |
---|---|---|
committer | Adam NAILI | 2017-12-27 17:19:23 +0100 |
commit | f39e6e3be66ff6077dd83094850232a46a21e624 (patch) | |
tree | b201d6718cd2c550b4ba5ff8e12b084a7171f0c5 /include | |
parent | ee98053ef83869033713c8c7d6d487457d6443d8 (diff) | |
parent | f5ff85f3c7e7d6bf11a423c497d2b3ce76cfafd8 (diff) | |
download | morpher-f39e6e3be66ff6077dd83094850232a46a21e624.tar.gz |
Merge remote-tracking branch 'origin/master' into gui
Diffstat (limited to 'include')
-rw-r--r-- | include/blender/blender.h | 2 | ||||
-rw-r--r-- | include/common/geom.h | 54 | ||||
-rw-r--r-- | include/common/matrix.h | 51 | ||||
-rw-r--r-- | include/morpher/matrix.h | 41 | ||||
-rw-r--r-- | include/morpher/morphing.h | 58 | ||||
-rw-r--r-- | include/morpher/quadrilateral.h | 39 | ||||
-rw-r--r-- | include/morpher/trianglemap.h | 143 |
7 files changed, 336 insertions, 52 deletions
diff --git a/include/blender/blender.h b/include/blender/blender.h index 8e89208..26ff802 100644 --- a/include/blender/blender.h +++ b/include/blender/blender.h | |||
@@ -8,7 +8,7 @@ | |||
8 | 8 | ||
9 | #include "common/time.h" | 9 | #include "common/time.h" |
10 | #include "blender/canvas.h" | 10 | #include "blender/canvas.h" |
11 | #include "morpher/morpher.h" | 11 | #include "morpher/morphing.h" |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * Function: blender_blend_canvas | 14 | * Function: blender_blend_canvas |
diff --git a/include/common/geom.h b/include/common/geom.h index a843c76..b3564a5 100644 --- a/include/common/geom.h +++ b/include/common/geom.h | |||
@@ -38,6 +38,46 @@ typedef struct { | |||
38 | CartesianVector origin, target; | 38 | CartesianVector origin, target; |
39 | } CartesianMapping; | 39 | } CartesianMapping; |
40 | 40 | ||
41 | |||
42 | /** | ||
43 | * Function: m | ||
44 | * Shorthand for an identity mapping. | ||
45 | * | ||
46 | * Parameters: | ||
47 | * x - the x-coordinate | ||
48 | * y - the y-coordinate | ||
49 | * | ||
50 | * Returns: | ||
51 | * A cartesian identity mapping | ||
52 | */ | ||
53 | CartesianMapping m(int x, int y); | ||
54 | |||
55 | /** | ||
56 | * Function: v | ||
57 | * Shorthand for a vector. | ||
58 | * | ||
59 | * Parameters: | ||
60 | * x - the x-coordinate | ||
61 | * y - the y-coordinate | ||
62 | * | ||
63 | * Returns: | ||
64 | * An integer vector | ||
65 | */ | ||
66 | CartesianVector v(int x, int y); | ||
67 | |||
68 | /** | ||
69 | * Function: mappings_equals | ||
70 | * Compares two cartesian mappings. | ||
71 | * | ||
72 | * Parameters: | ||
73 | * m1 - the first mapping | ||
74 | * m2 - the second mapping | ||
75 | * | ||
76 | * Returns: | ||
77 | * T(m1 is equal to m2) | ||
78 | */ | ||
79 | bool mappings_equals(CartesianMapping m1, CartesianMapping m2); | ||
80 | |||
41 | /** | 81 | /** |
42 | * Function: vector_equals | 82 | * Function: vector_equals |
43 | * Compares two cartesian vectors. | 83 | * Compares two cartesian vectors. |
@@ -51,4 +91,18 @@ typedef struct { | |||
51 | */ | 91 | */ |
52 | bool vector_equals(CartesianVector v1, CartesianVector v2); | 92 | bool vector_equals(CartesianVector v1, CartesianVector v2); |
53 | 93 | ||
94 | /** | ||
95 | * Function: triangle_area | ||
96 | * Computes the area of a triangle. | ||
97 | * | ||
98 | * Parameters: | ||
99 | * v1 - first vertex | ||
100 | * v2 - second vertex | ||
101 | * v3 - third vertex | ||
102 | * | ||
103 | * Returns: | ||
104 | * The area of the triangle spawned by the three supplied vertices | ||
105 | */ | ||
106 | IntVector triangle_area(CartesianVector v1, CartesianVector v2, CartesianVector v3); | ||
107 | |||
54 | #endif | 108 | #endif |
diff --git a/include/common/matrix.h b/include/common/matrix.h deleted file mode 100644 index fe4a12a..0000000 --- a/include/common/matrix.h +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | #ifndef UPEM_MORPHING_MATRIX | ||
2 | #define UPEM_MORPHING_MATRIX | ||
3 | |||
4 | /** | ||
5 | * File: matrix.h | ||
6 | * Matrices representation and useful operations. | ||
7 | * | ||
8 | * See also: | ||
9 | * The film | ||
10 | */ | ||
11 | |||
12 | #include "geom.h" | ||
13 | |||
14 | /** | ||
15 | * Struct: IntSquareMatrix | ||
16 | * Represents a square integer matrix. | ||
17 | * | ||
18 | * Fields: | ||
19 | * **elements - NULL-terminated array of element pointers | ||
20 | * dim - dimension | ||
21 | */ | ||
22 | typedef struct { | ||
23 | IntVector **elements; | ||
24 | IntVector dim; | ||
25 | } IntSquareMatrix; | ||
26 | |||
27 | /** | ||
28 | * Function: matrix_int_det | ||
29 | * Computes and returns the determinant of a square integer matrix. | ||
30 | * | ||
31 | * Parameters: | ||
32 | * *matrix - pointer to input matrix | ||
33 | * | ||
34 | * Returns: | ||
35 | * The integer determinant | ||
36 | */ | ||
37 | IntVector matrix_int_det(IntSquareMatrix *matrix); | ||
38 | |||
39 | /** | ||
40 | * Function: matrix_reshape | ||
41 | * Reshapes a flat vector into a bi-dimensional row pointer array. | ||
42 | * | ||
43 | * Parameters: | ||
44 | * **bi_dim - pointer to the result row array | ||
45 | * *flat - flat vector | ||
46 | * width - number of elements per row | ||
47 | * height - number of rows | ||
48 | */ | ||
49 | void matrix_reshape(IntVector **bi_dim, IntVector *flat, int width, int height); | ||
50 | |||
51 | #endif | ||
diff --git a/include/morpher/matrix.h b/include/morpher/matrix.h new file mode 100644 index 0000000..8118727 --- /dev/null +++ b/include/morpher/matrix.h | |||
@@ -0,0 +1,41 @@ | |||
1 | #ifndef UPEM_MORPHING_MATRIX | ||
2 | #define UPEM_MORPHING_MATRIX | ||
3 | |||
4 | /** | ||
5 | * File: matrix.h | ||
6 | * Determinant operations. | ||
7 | * | ||
8 | * See also: | ||
9 | * The film | ||
10 | */ | ||
11 | |||
12 | #include "common/geom.h" | ||
13 | |||
14 | /** | ||
15 | * Function: matrix_int_det2 | ||
16 | * Computes and returns the determinant of a square integer matrix of size 2. | ||
17 | * | ||
18 | * Parameters: | ||
19 | * uij - element at the i-th row and j-th column, counting from 1 | ||
20 | * | ||
21 | * Returns: | ||
22 | * The integer determinant | ||
23 | */ | ||
24 | IntVector matrix_int_det2(IntVector u11, IntVector u12, | ||
25 | IntVector u21, IntVector u22); | ||
26 | |||
27 | /** | ||
28 | * Function: matrix_int_det3 | ||
29 | * Computes and returns the determinant of a square integer matrix of size 3. | ||
30 | * | ||
31 | * Parameters: | ||
32 | * uij - element at the i-th row and j-th column, counting from 1 | ||
33 | * | ||
34 | * Returns: | ||
35 | * The integer determinant | ||
36 | */ | ||
37 | IntVector matrix_int_det3(IntVector u11, IntVector u12, IntVector u13, | ||
38 | IntVector u21, IntVector u22, IntVector u23, | ||
39 | IntVector u31, IntVector u32, IntVector u33); | ||
40 | |||
41 | #endif | ||
diff --git a/include/morpher/morphing.h b/include/morpher/morphing.h new file mode 100644 index 0000000..028cd87 --- /dev/null +++ b/include/morpher/morphing.h | |||
@@ -0,0 +1,58 @@ | |||
1 | #ifndef UPEM_MORPHING_MORPHING | ||
2 | #define UPEM_MORPHING_MORPHING | ||
3 | |||
4 | /** | ||
5 | * File: morphing.h | ||
6 | * Coordinate mapping for morphing transforms. | ||
7 | */ | ||
8 | |||
9 | #include "common/geom.h" | ||
10 | #include "common/time.h" | ||
11 | #include "morpher/trianglemap.h" | ||
12 | |||
13 | /** | ||
14 | * Struct: Morphing | ||
15 | * Represents an abstract coordinate transform from a source to a destination coordinate matrix, | ||
16 | * constrained by a given set of points. | ||
17 | * | ||
18 | * Fields: | ||
19 | * dim - dimension in pixels | ||
20 | * *first - the first triangle in the linked list | ||
21 | * *center - the center triangle | ||
22 | */ | ||
23 | typedef struct { | ||
24 | CartesianVector dim; | ||
25 | TriangleMap *first, *center; | ||
26 | } Morphing; | ||
27 | |||
28 | /** | ||
29 | * Function: morphing_init | ||
30 | * Initialises a morphing. | ||
31 | * | ||
32 | * Parameters: | ||
33 | * width - coordinate matrix width in pixels | ||
34 | * height - coordinate matrix height in pixels | ||
35 | */ | ||
36 | Morphing *morphing_create(IntVector width, IntVector height); | ||
37 | |||
38 | /** | ||
39 | * Function: morphing_free | ||
40 | * Frees any resources allocated to a morphing. | ||
41 | * | ||
42 | * Parameters: | ||
43 | * *m - pointer to the morphing to destroy | ||
44 | */ | ||
45 | void morphing_destroy(Morphing *m); | ||
46 | |||
47 | /** | ||
48 | * Function: morphing_add_constraint | ||
49 | * Adds a constraint point to a morphing. | ||
50 | * | ||
51 | * Parameters: | ||
52 | * *m - pointer to the morphing to alter | ||
53 | * origin - constraint point coordinates on the origin matrix | ||
54 | * destination - constraint point coordinates on the target matrix | ||
55 | */ | ||
56 | void morphing_add_constraint(Morphing *m, CartesianVector origin, CartesianVector destination); | ||
57 | |||
58 | #endif | ||
diff --git a/include/morpher/quadrilateral.h b/include/morpher/quadrilateral.h new file mode 100644 index 0000000..c8cf3a1 --- /dev/null +++ b/include/morpher/quadrilateral.h | |||
@@ -0,0 +1,39 @@ | |||
1 | #ifndef UPEM_MORPHING_QUADRILATERAL | ||
2 | #define UPEM_MORPHING_QUADRILATERAL | ||
3 | |||
4 | /** | ||
< |