void testTranslate() { Point2D point; point.setX(3); point.setY(5); point.translate(2, 3); point.print(); }
bool ScenRectangle::pointOverlap(const Point2D &point) { //Trasformo il punto nelle coordinate locali del rettangolo Point2D pt; pt=point; pt.translate(-p.x,-p.y); pt.rotate(-rotAngle); //Controllo se il punto si trova dentro il rettangolo axis-alined if((0<=pt.x)&&(pt.x<=width)) { if((0<=pt.y)&&(pt.y<=height)) return true; else return false; } else return false; }//Fine pointOverlap
bool ScenRectangle::nodeOverlap(Node &node) { Point2D pCtrl; pCtrl=node.getPosition(); //Trasformo il punto nelle coordinate locali del rettangolo pCtrl.translate(-p.x,-p.y); pCtrl.rotate(-rotAngle); /*Point2D pTest; pTest=node.getPosition(); //Trasformo il punto nelle coordinate locali del rettangolo pTest.translate(-p.x,-p.y); pTest.rotate(-rotAngle);*/ ////////////////////// if((pCtrl.x>=-node.getRadius())&&(pCtrl.x<=width+node.getRadius())) { if((pCtrl.y>=-node.getRadius())&&(pCtrl.y<=height+node.getRadius())) {return true;} } return false; //////////////////////// /*float radius2=node.getRadius()*node.getRadius(); if(pTest.x<0) pTest.x=0; if(pTest.x>width) pTest.x=width; if(pTest.y<0) pTest.y=0; if(pTest.y>height) pTest.y=height; return (((pCtrl.x-pTest.x)*(pCtrl.x-pTest.x)+ (pCtrl.y-pTest.y)*(pCtrl.y-pTest.y))<=radius2);*/ }//Fine nodeOverlap