summaryrefslogtreecommitdiff
path: root/libgeometry/triangle.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgeometry/triangle.c')
-rw-r--r--libgeometry/triangle.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libgeometry/triangle.c b/libgeometry/triangle.c
new file mode 100644
index 0000000..a8bbf0f
--- /dev/null
+++ b/libgeometry/triangle.c
@@ -0,0 +1,9 @@
+#include <u.h>
+#include <libc.h>
+#include "../geometry.h"
+
+Point3
+centroid(Triangle3 t)
+{
+ return divpt3(addpt3(t.p0, addpt3(t.p1, t.p2)), 3);
+}