summaryrefslogtreecommitdiff
path: root/test/common
diff options
context:
space:
mode:
authorpacien2017-12-28 01:19:45 +0100
committerpacien2017-12-28 01:19:45 +0100
commitc29e4ecb7de4cb10f48b2526bc1abae847c718e2 (patch)
tree03b439e2ed82ddab30823a8782cfdb8ebce1a349 /test/common
parentf5ff85f3c7e7d6bf11a423c497d2b3ce76cfafd8 (diff)
downloadmorpher-c29e4ecb7de4cb10f48b2526bc1abae847c718e2.tar.gz
Add new geometry common types and functions
Signed-off-by: pacien <pacien.trangirard@pacien.net>
Diffstat (limited to 'test/common')
-rw-r--r--test/common/geom.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/common/geom.c b/test/common/geom.c
new file mode 100644
index 0000000..f05e0a1
--- /dev/null
+++ b/test/common/geom.c
@@ -0,0 +1,21 @@
1#include "common/geom.h"
2#include <assert.h>
3
4static void test_square_area() {
5 assert(square_area(v(0, 0), v(10, 0), v(10, 10)) == 100);
6 assert(square_area(v(0, 0), v(0, 10), v(10, 10)) == -100);
7}
8
9static void test_cartesian_barycentric_vectors() {
10 Triangle t = {{v(0, 0), v(10, 0), v(10, 10)}};
11 CartesianVector c = v(3, 2);
12 BarycentricVector bv = cartesian_to_barycentric(t, c);
13 assert(barycentric_vector_equals(bv, b(0.7, 0.1)));
14 assert(vector_equals(barycentric_to_cartesian(t, bv), c));
15}
16
17int main(int argc, char **argv) {
18 test_square_area();
19 test_cartesian_barycentric_vectors();
20 return 0;
21}