# locking points

Hi everyone!

I have a question, how do i lock the the point i’ve created on each other, so i can rotate. without letting lose the points?

Does anyone have some tips on how to do it?

I’ve made a short movie on how I want it: https://vimeo.com/41737584

Seems like the easiest way would be to get fancy with ofPushMatrix() ofPopMatrix and your translates and rotates

ofPushMatrix();
ofTranslate(40,50);
ofRotateZ(variable); //mess with whether rotation or translation comes first to determine different behaviors
ofRect(0,0,40,40);  //this will be translated and then rotated
ofPopMatrix();

then just encapsulate everything in their own matrix sets so they stay the same relative to eachother

Yes, that would be logical, but the problem with my idea it that i store the ofpoints in an array

First I make an triangle

float move = 200;

// pt 1
float theta = TWO_PI * 1 / n;

ofVec2f cur = ofVec2f(cos(theta), sin(theta)) * radius;
cur +=   ofVec2f(0, 0) *offset;

startPoints.push_back(ofPoint( move+cur.x,move+cur.y));
line.lineTo(cur);

// pt 2
theta = TWO_PI * (1+1) / n;
cur = ofVec2f(cos(theta), sin(theta)) * radius;
cur +=   ofVec2f(0, 0) *offset;

startPoints.push_back(ofPoint(move+cur.x,move+cur.y));
line.lineTo(cur);

// pt 3
cur = ofVec2f(0, sin(theta)) ;

startPoints.push_back(ofPoint(move+cur.x,move+cur.y));
line.lineTo(cur);

line.close();

activeEllipse.resize(startPoints.size());

t.tessellateToMesh(line, OF_POLY_WINDING_NONZERO, mesh);

//	for(int i=0; i<startPoints.size(); i++){
//			startPoints[i].x += ofGetScreenWidth()/2;
//			startPoints[i].x += ofGetScreenH()/2;
//		}

}

Then there’s an class that checks if there’s anything selected:

void ofxTriangleShape::touchDown(ofTouchEventArgs &touch){

vector<vector<ofPoint> > pointsTouch;
pointsTouch.resize(points.size());

for(int i=0; i<points.size(); i++){
for(int x=0; x<points[i].size();x++){
pointsTouch[i].push_back(ofPoint(centerX + points[i][x].x, centerY + points[i][x].y));
}

if(ofInsidePoly(touch.x, touch.y, pointsTouch[i]) == true){

cout<<"shaperTouch"<<endl;

collector.setBool(shapesi,shapesx, false);
collector.falseBool(shapesi,shapesx, false);
cout<<"afterFalseBoool"<<endl;
cout<<collector.getSize()<<endl;
cout<<collector.sizeBool()<<endl;

continue;
//collector.clearBool(shapesi);
//fillSlice[i] = true;

//	collector.setBool(shapesi,shapesx, false);
}
}

}

then i store them in an vector array:

storedTriangleValues.resize(storedTriangleValues.size()+1);
storedTriangleValues[storedTriangleValues.size()-1] = points;
//	storedTriangleValues.push_back(points);

}

When the mouse is moved, i adapt the values in the array, like this:

void ofxCollector::pointMove(float \$x, float \$y){

try {
for(int i=0; i<storedTriangleValues.size(); i++){

for(int x=0; x<storedTriangleValues.at(i).size(); x++){

storedTriangleValues[i][x].x -= \$x;
storedTriangleValues[i][x].y -= \$y;
}
}
}

catch (string& s) {
std::cout << "caught it: \"" << s << "\"" << endl;

}

}

After the program is finished i want to transfer the data to an mysql database, so I can read it on my installation. So i think just using ofRotate doesn’t work for me Any suggestions?