diff options
author | pacien | 2017-12-22 01:53:55 +0100 |
---|---|---|
committer | pacien | 2017-12-22 01:55:25 +0100 |
commit | a767c658cb603de9ec9f0577627b9b32cbf82b2b (patch) | |
tree | 084b023cf34a60e4cbbc79053723bf23c96fa678 /src/common/geom.c | |
parent | 7af561eccb7b4210e4e8233d53876b7af5607234 (diff) | |
download | morpher-a767c658cb603de9ec9f0577627b9b32cbf82b2b.tar.gz |
Simplify and add geom. and matrix utility functions
Signed-off-by: pacien <pacien.trangirard@pacien.net>
Diffstat (limited to 'src/common/geom.c')
-rw-r--r-- | src/common/geom.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/common/geom.c b/src/common/geom.c index 7abb422..219270f 100644 --- a/src/common/geom.c +++ b/src/common/geom.c | |||
@@ -1,5 +1,24 @@ | |||
1 | #include "common/geom.h" | 1 | #include "common/geom.h" |
2 | #include "morpher/matrix.h" | ||
3 | |||
4 | CartesianMapping m(int x, int y) { | ||
5 | return (CartesianMapping) {{x, y}, | ||
6 | {x, y}}; | ||
7 | } | ||
8 | |||
9 | CartesianVector v(int x, int y) { | ||
10 | return (CartesianVector) {x, y}; | ||
11 | } | ||
12 | |||
13 | bool mappings_equals(CartesianMapping m1, CartesianMapping m2) { | ||
14 | return vector_equals(m1.origin, m2.origin) && vector_equals(m1.target, m2.target); | ||
15 | } | ||
2 | 16 | ||
3 | bool vector_equals(CartesianVector v1, CartesianVector v2) { | 17 | bool vector_equals(CartesianVector v1, CartesianVector v2) { |
4 | return v1.x == v2.x && v1.y == v2.y; | 18 | return v1.x == v2.x && v1.y == v2.y; |
5 | } | 19 | } |
20 | |||
21 | IntVector triangle_area(CartesianVector v1, CartesianVector v2, CartesianVector v3) { | ||
22 | return matrix_int_det2(v1.x - v3.x, v2.x - v3.x, | ||
23 | v1.y - v3.y, v2.y - v3.y); | ||
24 | } | ||