aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore6
-rw-r--r--Makefile4
-rw-r--r--geom.hpp61
-rw-r--r--lamiraux-sekhavat-laumond-tro.pdfbin0 -> 455145 bytes
-rw-r--r--main.cpp10
5 files changed, 81 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..bbe7d3f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+*.o
+*~
+*.swp
+
+pathfind
+
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..d1b0544
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+BIN=pathfind
+
+$(BIN): *.cpp *.hpp
+ g++ -o $@ *.cpp -lm
diff --git a/geom.hpp b/geom.hpp
new file mode 100644
index 0000000..056a36e
--- /dev/null
+++ b/geom.hpp
@@ -0,0 +1,61 @@
+#pragma once
+
+#include <math.h>
+
+struct vec {
+ double x, y;
+
+ vec(double xx, double yy) : x(xx), y(yy) {}
+
+ double norm() const {
+ return sqrt(x*x + y*y);
+ }
+
+ double angle() const {
+ double xx = x / norm();
+ double a = acos(x);
+ return (y > 0 ? a : -a);
+ }
+
+ vec operator+ (const vec& o) const {
+ return vec(x + o.x, y + o.y);
+ }
+};
+
+struct line {
+ // Line defined by ax + by + c = 0
+ double a, b, c;
+
+ line(double aa, double bb, double cc) : a(aa), b(bb), c(cc) {}
+
+ double dist(double x, double y) const {
+ // TODO
+ return 1;
+ }
+
+ double angle() const {
+ return vec(-b, a).angle();
+ }
+
+};
+
+struct circle {
+ vec c;
+ double r;
+
+ circle(double x, double y, double rr) : c(x, y), r(rr) {}
+ circle(vec cc, double rr) : c(cc), r(rr) {}
+};
+
+struct circpoint {
+ circle c;
+ double theta;
+
+ circpoint(circle cc, double th) : c(cc), theta(th) {}
+
+ vec pos() const {
+ return c.c + vec(c.r * cos(theta), c.r * sin(theta));
+ }
+};
+
+/* vim: set ts=4 sw=4 tw=0 noet :*/
diff --git a/lamiraux-sekhavat-laumond-tro.pdf b/lamiraux-sekhavat-laumond-tro.pdf
new file mode 100644
index 0000000..9aa9ac7
--- /dev/null
+++ b/lamiraux-sekhavat-laumond-tro.pdf
Binary files differ
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..b5a4386
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,10 @@
+#include <stdio.h>
+
+#include "geom.hpp"
+
+int main() {
+ printf("%.10f\n", M_PI);
+ return 0;
+}
+
+/* vim: set ts=4 sw=4 tw=0 noet :*/