aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Fabre-Monplaisir <jean-isaac-fm@live.fr>2015-01-08 16:25:57 +0100
committerJean Fabre-Monplaisir <jean-isaac-fm@live.fr>2015-01-08 16:25:57 +0100
commitaefe4ae1206c4c5d1bc6a581ea02768d05a2b328 (patch)
treea51d867caef8426177518073dce9247637702ec5
parent045c846407d945f0822b059622c68387a6b8c61d (diff)
downloadRobotique-Projet-aefe4ae1206c4c5d1bc6a581ea02768d05a2b328.tar.gz
Robotique-Projet-aefe4ae1206c4c5d1bc6a581ea02768d05a2b328.zip
implementation des constructeurs de droite et distance à une droite
-rw-r--r--geom.hpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/geom.hpp b/geom.hpp
index abb71c0..09b2f36 100644
--- a/geom.hpp
+++ b/geom.hpp
@@ -27,10 +27,15 @@ 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);
+
+ }
+
double dist(vec p) const {
- // TODo
- return 1;
+ return abs(a*p.x+b*p.y+c)/sqrt(a*a+b*b);
}
double angle() const {
@@ -45,7 +50,7 @@ struct segment {
segment(vec pa, vec pb) : a(pa), b(pb), {}
double dist(vec p) const {
- // TODO
+
return 1;
}
};