aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Fabre-Monplaisir <jean-isaac-fm@live.fr>2015-01-08 17:43:29 +0100
committerJean Fabre-Monplaisir <jean-isaac-fm@live.fr>2015-01-08 17:43:29 +0100
commit803d245cc906b6397ef1952df1f858cc46d0c444 (patch)
tree9015ae42a0492dc69c675503053b309ca685ee66
parent4bf549ed7af5d2b972a4be616420ffc0958d6baa (diff)
downloadRobotique-Projet-803d245cc906b6397ef1952df1f858cc46d0c444.tar.gz
Robotique-Projet-803d245cc906b6397ef1952df1f858cc46d0c444.zip
distance à un cercle - ça compile !
-rw-r--r--geom.hpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/geom.hpp b/geom.hpp
index daeedaa..603abf9 100644
--- a/geom.hpp
+++ b/geom.hpp
@@ -17,10 +17,6 @@ struct vec {
return x*x + y*y;
}
- double sqnorm() const {
- return x*x + y*y;
- }
-
double angle() const {
double xx = x / norm();
double a = acos(x);
@@ -115,9 +111,9 @@ struct segment {
double dist(vec p) const {
double scal = vec::dot(b-a, p-a);
- double sqn = (b-a).sqnorm
- if(scal > sqn)return (p-b).norm ;
- if(scal < 0) return (p-a).norm ;
+ double sqn = (b-a).sqnorm();
+ if (scal > sqn) return (p-b).norm();
+ if (scal < 0) return (p-a).norm();
return line(a,b).dist(p);
}
};
@@ -134,8 +130,10 @@ struct circle {
}
double dist(vec p) const {
- // TODO
- return 1;
+ // distance à un cercle
+ double d = (c-p).norm() ;
+ if (d > r) return (d - r);
+ return 0;
}
};