bool zoneManager::checkInZone(ofPtr<clamourNode> n, ofPtr<zone> z) { // cout << "check in zone \n"; // return clamourUtils::pointInPath(z->getOuterEdge(), n->getMeanPos_abs()); ofPoint intersect; bool isIntersect = clamourUtils::pathInPath( n->getOuterEdge(), z->getOuterEdge(), intersect); if(isIntersect)n->setIntersect(intersect); return isIntersect; }
void zoneManager::repellNode(ofPtr<clamourNode> n, ofPtr<zone> z) { // cout << "repell \n"; //finding centroid is not solved here so this method only works if zones drawn from the center ofVec2f v = n->getMeanPos_abs() - n->getIntersect(); ofPoint p = clamourUtils::getInsideIntersect(z->getOuterEdge(), z->getPos_abs(), n->getIntersect()); p = p + v; n->setRawPos_abs(p); n->modifyHistory(); }
void zoneManager::containNode(ofPtr<clamourNode> n, ofPtr<zone> z) { ofPoint intersect; bool isOutside = clamourUtils::pathOutPath( n->getOuterEdge(), z->getOuterEdge(), intersect); if(isOutside) { ofVec2f v = n->getMeanPos_abs() - intersect; ofVec2f vi(intersect - z->getPos_abs()); ofPoint p = clamourUtils::getInsideIntersect(z->getOuterEdge(), z->getPos_abs(), intersect); ofVec2f d = (p - z->getPos_abs()); p -= d * 0.05; //move it slightly inside p = p + v; if(d.length() * 0.95 < vi.length()) { //only if necessary n->setRawPos_abs(p); n->modifyHistory(); } } }