diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2015-01-07 14:38:45 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2015-01-07 14:38:45 +0100 |
commit | 8151e2cde5d855b410431764bff9c0e01b93efa9 (patch) | |
tree | 7688d866c058ab2333b13a15766e5fbdc7af396f | |
download | Robotique-Projet-8151e2cde5d855b410431764bff9c0e01b93efa9.tar.gz Robotique-Projet-8151e2cde5d855b410431764bff9c0e01b93efa9.zip |
Initial commit.
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | geom.hpp | 61 | ||||
-rw-r--r-- | lamiraux-sekhavat-laumond-tro.pdf | bin | 0 -> 455145 bytes | |||
-rw-r--r-- | main.cpp | 10 |
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 Binary files differnew file mode 100644 index 0000000..9aa9ac7 --- /dev/null +++ b/lamiraux-sekhavat-laumond-tro.pdf 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 :*/ |