aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-01-08 15:29:25 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2015-01-08 15:29:25 +0100
commit3e7f796b17150cb96b332c619271152df3015756 (patch)
tree5529daae284124215046793158792b2e9c2874fb
parentad4173e1c2bb55d2cce827067dfd132e8a6a7ac4 (diff)
parentaefe4ae1206c4c5d1bc6a581ea02768d05a2b328 (diff)
downloadRobotique-Projet-3e7f796b17150cb96b332c619271152df3015756.tar.gz
Robotique-Projet-3e7f796b17150cb96b332c619271152df3015756.zip
Merge branch 'master' of github.com:Alexis211/Robotique
Conflicts: geom.hpp
-rw-r--r--geom.hpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/geom.hpp b/geom.hpp
index e9a4512..1b5c058 100644
--- a/geom.hpp
+++ b/geom.hpp
@@ -67,6 +67,11 @@ struct line {
double a, b, c;
line(double aa, double bb, double cc) : a(aa), b(bb), c(cc) {}
+ line(vec p1, vec p2) {
+ a = p1.x-p2.x ;
+ b = p1.y-p2.y ;
+ c = p1.x*(p2.x-p1.x)+p1.y*(p2.y-p1.y);
+ }
bool on_line(vec p) const {
return a * p.x + b * p.y + c == 0;
@@ -74,8 +79,7 @@ struct line {
double dist(vec p) const {
// calculate distance from p to the line
- // TODO
- return 1;
+ return abs(a*p.x+b*p.y+c)/sqrt(a*a+b*b);
}
vec proj(vec p) const {
@@ -102,7 +106,7 @@ struct segment {
}
double dist(vec p) const {
- // TODO
+
return 1;
}
};