annotate src/coord.c @ 2:31402929c587

Transform position
author Thinker K.F. Li <thinker@branda.to>
date Wed, 23 Jul 2008 16:07:37 +0800
parents b5c0162ccf69
children 164162781a7a
rev   line source
2
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
1 /*! \brief Implement coordination tranform mechanism.
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
2 * \file
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
3 * This file implements coordination transforming for containers.
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
4 */
1
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
5 #include <stdio.h>
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
6 #include <string.h>
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
7
2
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
8 typedef float co_aix;
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
9 /*! \brief A coordination system.
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
10 *
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
11 * It have a transform function defined by matrix to transform
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
12 * coordination from source space to target space.
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
13 * Source space is where the contained is drawed, and target space
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
14 * is where the coordination of parent container of the element
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
15 * represented by this coord object.
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
16 */
1
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
17 typedef struct coord {
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
18 int seq;
2
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
19 co_aix matrix[6];
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
20 co_aix aggr_matrix[6];
1
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
21 struct coord *parent;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
22 struct coord *children, *sibling;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
23 } coord_t;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
24
2
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
25 #define MUL(a, b) ((a) * (b))
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
26 #define ADD(a, b) ((a) + (b))
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
27 #define DIV(a, b) ((a) / (b))
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
28 #define SUB(a, b) ((a) - (b))
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
29
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
30 static void mul_matrix(co_aix *m1, co_aix *m2, co_aix *dst) {
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
31 dst[0] = ADD(MUL(m1[0], m2[0]), MUL(m1[1], m2[3]));
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
32 dst[1] = ADD(MUL(m1[0], m2[1]), MUL(m1[1], m2[4]));
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
33 dst[2] = ADD(ADD(MUL(m1[0], m2[2]), MUL(m1[1], m2[5])), m1[2]);
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
34 dst[3] = ADD(MUL(m1[3], m2[0]), MUL(m1[4], m2[3]));
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
35 dst[4] = ADD(MUL(m1[3], m2[1]), MUL(m1[4], m2[4]));
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
36 dst[5] = ADD(ADD(MUL(m1[3], m2[2]), MUL(m1[4], m2[5])), m1[5]);
1
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
37 }
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
38
2
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
39 /*! \brief Compute agrregated transform function.
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
40 *
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
41 * Base on parent's aggregated matrix if it is existed, or use transform
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
42 * matrix as aggregated matrix.
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
43 */
1
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
44 static void compute_transform_function(coord_t *visit) {
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
45 if(visit->parent)
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
46 mul_matrix(visit->parent->aggr_matrix,
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
47 visit->matrix, visit->aggr_matrix);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
48 else
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
49 memcpy(visit->aggr_matrix, visit->matrix, sizeof(visit->matrix));
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
50 }
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
51
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
52 /*! \brief Update aggregate matrices of elements under a sub-tree.
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
53 *
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
54 * A subtree is specified by the root of it. All elements in the subtree
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
55 * are effected by that changes of matrix of the subtree root.
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
56 */
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
57 void update_aggr_matrix(coord_t *start) {
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
58 coord_t *visit, *child, *next;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
59
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
60 compute_transform_function(start);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
61
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
62 visit = start;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
63 while(visit) {
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
64 child = visit->children;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
65 while(child) {
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
66 compute_transform_function(child);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
67 child = child->sibling;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
68 }
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
69
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
70 if(visit->children)
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
71 visit = visit->children;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
72 else if(visit->sibling)
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
73 visit = visit->sibling;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
74 else {
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
75 next = NULL;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
76 while(visit->parent && visit->parent != start) {
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
77 visit = visit->parent;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
78 if(visit->sibling) {
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
79 next = visit->sibling;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
80 break;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
81 }
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
82 }
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
83 visit = next;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
84 }
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
85 }
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
86 }
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
87
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
88 void coord_init(coord_t *co, coord_t *parent) {
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
89 memset(co, 0, sizeof(coord_t));
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
90 if(parent) {
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
91 co->parent = parent;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
92 co->sibling = parent->children;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
93 parent->children = co;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
94 }
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
95 co->matrix[0] = 1;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
96 co->matrix[4] = 1;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
97 }
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
98
2
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
99 void coord_trans_pos(coord_t *co, co_aix *x, co_aix *y) {
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
100 co_aix nx, ny;
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
101
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
102 nx = ADD(ADD(MUL(co->aggr_matrix[0], *x),
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
103 MUL(co->aggr_matrix[1], *y)),
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
104 co->aggr_matrix[2]);
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
105 ny = ADD(ADD(MUL(co->aggr_matrix[3], *x),
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
106 MUL(co->aggr_matrix[4], *y)),
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
107 co->aggr_matrix[5]);
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
108 *x = nx;
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
109 *y = ny;
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
110 }
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
111
1
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
112 #ifdef UNITTEST
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
113
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
114 #include <CUnit/Basic.h>
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
115
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
116 void test_update_aggr_matrix(void) {
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
117 coord_t elms[6];
2
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
118 co_aix x, y;
1
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
119
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
120 coord_init(elms, NULL);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
121 coord_init(elms + 1, elms);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
122 coord_init(elms + 2, elms);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
123 coord_init(elms + 3, elms + 1);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
124 coord_init(elms + 4, elms + 1);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
125 coord_init(elms + 5, elms + 2);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
126
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
127 /* | 2 -1 0 |
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
128 * | 0 1 0 |
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
129 * | 0 0 1 |
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
130 */
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
131 elms[0].matrix[0] = 2;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
132 elms[0].matrix[1] = -1;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
133
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
134 /* | 1 3 0 |
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
135 * | 5 1 0 |
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
136 * | 0 0 1 |
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
137 */
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
138 elms[1].matrix[1] = 3;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
139 elms[1].matrix[3] = 5;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
140
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
141 update_aggr_matrix(elms);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
142
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
143 /* | -3 5 0 |
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
144 * | 5 1 0 |
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
145 * | 0 0 1 |
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
146 */
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
147 CU_ASSERT(elms[3].aggr_matrix[0] == -3);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
148 CU_ASSERT(elms[3].aggr_matrix[1] == 5);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
149 CU_ASSERT(elms[3].aggr_matrix[2] == 0);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
150 CU_ASSERT(elms[3].aggr_matrix[3] == 5);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
151 CU_ASSERT(elms[3].aggr_matrix[4] == 1);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
152 CU_ASSERT(elms[3].aggr_matrix[5] == 0);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
153
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
154 CU_ASSERT(elms[4].aggr_matrix[0] == -3);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
155 CU_ASSERT(elms[4].aggr_matrix[1] == 5);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
156 CU_ASSERT(elms[4].aggr_matrix[2] == 0);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
157 CU_ASSERT(elms[4].aggr_matrix[3] == 5);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
158 CU_ASSERT(elms[4].aggr_matrix[4] == 1);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
159 CU_ASSERT(elms[4].aggr_matrix[5] == 0);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
160
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
161 CU_ASSERT(elms[5].aggr_matrix[0] == 2);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
162 CU_ASSERT(elms[5].aggr_matrix[1] == -1);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
163 CU_ASSERT(elms[5].aggr_matrix[2] == 0);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
164 CU_ASSERT(elms[5].aggr_matrix[3] == 0);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
165 CU_ASSERT(elms[5].aggr_matrix[4] == 1);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
166 CU_ASSERT(elms[5].aggr_matrix[5] == 0);
2
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
167
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
168 x = 50;
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
169 y = 99;
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
170 coord_trans_pos(elms + 5, &x, &y);
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
171 CU_ASSERT(x == 1);
31402929c587 Transform position
Thinker K.F. Li <thinker@branda.to>
parents: 1
diff changeset
172 CU_ASSERT(y == 99);
1
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
173 }
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
174
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
175 CU_pSuite get_coord_suite(void) {
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
176 CU_pSuite suite;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
177
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
178 suite = CU_add_suite("Suite_coord", NULL, NULL);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
179 CU_ADD_TEST(suite, test_update_aggr_matrix);
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
180
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
181 return suite;
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
182 }
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
183
b5c0162ccf69 Coordination tranforming
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
184 #endif