From a767c658cb603de9ec9f0577627b9b32cbf82b2b Mon Sep 17 00:00:00 2001 From: pacien Date: Fri, 22 Dec 2017 01:53:55 +0100 Subject: Simplify and add geom. and matrix utility functions Signed-off-by: pacien --- src/common/geom.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/common/geom.c') 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 @@ #include "common/geom.h" +#include "morpher/matrix.h" + +CartesianMapping m(int x, int y) { + return (CartesianMapping) {{x, y}, + {x, y}}; +} + +CartesianVector v(int x, int y) { + return (CartesianVector) {x, y}; +} + +bool mappings_equals(CartesianMapping m1, CartesianMapping m2) { + return vector_equals(m1.origin, m2.origin) && vector_equals(m1.target, m2.target); +} bool vector_equals(CartesianVector v1, CartesianVector v2) { return v1.x == v2.x && v1.y == v2.y; } + +IntVector triangle_area(CartesianVector v1, CartesianVector v2, CartesianVector v3) { + return matrix_int_det2(v1.x - v3.x, v2.x - v3.x, + v1.y - v3.y, v2.y - v3.y); +} -- cgit v1.2.3