From 1f56608950aeaa3941c567a21de23f14106b395a Mon Sep 17 00:00:00 2001 From: Sara Date: Mon, 23 Oct 2023 21:52:38 +0200 Subject: [PATCH 1/3] shape now has shape_get_points for getting the List of points --- src/shape.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/shape.c b/src/shape.c index a805284..17b47e3 100644 --- a/src/shape.c +++ b/src/shape.c @@ -141,6 +141,10 @@ void shape_insert_point(Shape* self, size_t at, Vector point) { list_insert(&self->points, &point, at); } +List* shape_get_points(Shape* self) { + return &self->points; +} + Vector shape_remove_point(Shape* self, size_t at) { Vector point = *list_at_as(Vector, &self->points, at); list_erase(&self->points, at); From fa2ca7241cb3452c95794f4520faebd0de170e45 Mon Sep 17 00:00:00 2001 From: Sara Date: Mon, 23 Oct 2023 21:52:44 +0200 Subject: [PATCH 2/3] added anglebetween to vmathf --- src/vmath.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vmath.h b/src/vmath.h index 3697372..07e5e02 100644 --- a/src/vmath.h +++ b/src/vmath.h @@ -120,6 +120,10 @@ Vector vrotatef(Vector a, float t) { }; } static inline +float vanglebetweenf(Vector a, Vector b) { + return vdotf(a, b) / (vmagnitudef(a) * vmagnitudef(b)); +} +static inline Vector vprojectf(Vector onto, Vector from) { float dot = vdotf(onto, from); return vmulff(onto, dot); From 0a9c6745ad6907688bf613c853ee23aafff86d1b Mon Sep 17 00:00:00 2001 From: Sara Date: Mon, 23 Oct 2023 21:52:58 +0200 Subject: [PATCH 3/3] added shape_get_points --- src/shape.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/shape.h b/src/shape.h index f0ec98b..650ab82 100644 --- a/src/shape.h +++ b/src/shape.h @@ -3,6 +3,7 @@ #include "vmath.h" #include "transform.h" +#include "list.h" typedef struct Shape Shape; @@ -21,6 +22,7 @@ extern Vector shape_get_point_transformed(Shape* self, size_t at, Transform tran extern void shape_set_point(Shape* self, size_t at, Vector point); extern void shape_add_point(Shape* self, Vector point); extern void shape_insert_point(Shape* self, size_t at, Vector point); +extern List* shape_get_points(Shape* self); extern Vector shape_remove_point(Shape* self, size_t at); extern Vector shape_get_median_point(Shape* self);