diff options
| author | Comment <tim@gray.(none)> | 2013-01-29 17:23:14 +0000 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-01-29 17:23:14 +0000 |
| commit | ed539c88af8e18ae3b505e324319b956944e0d91 (patch) | |
| tree | 3c35b84658c3ff057923ca87daca53ba14665afe /src/boundary.cpp | |
| parent | ba37049c44ff64b3c6482a5e2f199f178351a69f (diff) | |
working with accumulation
Diffstat (limited to 'src/boundary.cpp')
| -rwxr-xr-x | src/boundary.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/boundary.cpp b/src/boundary.cpp index 2425c4a..3e5b18c 100755 --- a/src/boundary.cpp +++ b/src/boundary.cpp @@ -37,13 +37,15 @@ void boundary::undo(){ }
void boundary::getCentroid(){
- float x=0;
float y=0;
+ float maxx=-1; + float minx=100000;
for (int i=0;i<points.size();i++) {
- x+=points[i].x;
y+=points[i].y;
+ minx=min(minx,points[i].x); + maxx=max(maxx,points[i].x);
}
- centroid=ofPoint(x/points.size(),y/points.size(),0);
+ centroid=ofPoint(minx+((maxx-minx)*0.1),y/points.size(),0);
}
bool boundary::contains(ofPoint p)
@@ -77,6 +79,16 @@ bool boundary::contains(ofPoint p) return false;
else
return true;
+} +int boundary::findPoint(ofPoint pos){ + int threshold=6; + int selected=-1; + for (int i=0;i<points.size();i++) { + if (abs(points[i].x-pos.x)<=threshold&&abs(points[i].x-pos.x)<=threshold) { + selected=i; + } + } + return selected; }
void boundary::openFile(string file) {
filename=file;
|
