From e2e45966d7a3ca7673bdbaadef5b5e8a38b0ff78 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 11 Oct 2012 19:43:47 +0100 Subject: initial commit --- src/boundary.cpp | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 src/boundary.cpp (limited to 'src/boundary.cpp') diff --git a/src/boundary.cpp b/src/boundary.cpp new file mode 100755 index 0000000..c30f676 --- /dev/null +++ b/src/boundary.cpp @@ -0,0 +1,79 @@ +#include "boundary.h" + +boundary::boundary() +{ + note=40; //middle C +} + +boundary::boundary(int _note) +{ + note=_note; +} + +boundary::~boundary() +{ +} + + +void boundary::draw(){ + if (points.size()>1) { + for (int i=0;i0) { + points.erase(points.end()-1); + getCentroid(); + } +} + +void boundary::getCentroid(){ + float x=0; + float y=0; + for (int i=0;i min(p1.y,p2.y)) { + if (p.y <= max(p1.y,p2.y)) { + if (p.x <= max(p1.x,p2.x)) { + if (p1.y != p2.y) { + xinters = (p.y-p1.y)*(p2.x-p1.x)/(p2.y-p1.y)+p1.x; + if (p1.x == p2.x || p.x <= xinters) + counter++; + } + } + } + } + p1 = p2; + } + + if (counter % 2 == 0) + return false; + else + return true; +} -- cgit v1.2.3