# Rotating points on a circle

I have drawn a 2D circle in X,Y,Z. I wanted to draw something on specific vertices of that circle and I managed to do it. When I wanted to move the circle, I wanted the vertices to get the updated position, so I created another array of vertices and calculated the new vertex positions.

Now I want to rotate the circle, and while rotating it, the vertices should get the new orientation. How can I do this?

``````void creature::drawCircle(Vec3f Pos,float radius, int segments )
{

// automatically determine the number of segments from the circumference
if( segments <= 0 ) {
segments = (int)math<double>::floor( radius * M_PI * 2 );
}
if( segments < 2 ) segments = 2;

GLfloat *verts = new float[(segments+2)*3];
GLfloat *vertsNew = new float[(segments+2)*3];
verts[0] = 0;
verts[1] = 0;
verts[2] = 0;
vertsNew[0] = 0;
vertsNew[1] = 0;
vertsNew[2] = 0;

//Create circle
for( int s = 0; s <= segments; s++ ) {
float t = s / (float)segments * 2.0f * 3.14159f;
verts[(s+1)*3+0] = math<float>::cos( t ) * radius;
verts[(s+1)*3+1] = math<float>::sin( t ) * radius;
verts[(s+1)*3+2] = 0;
}

//Transform points
for( int s = 0; s <= segments; s++ ) {
ci::Vec3f  m_newCirclePos;
m_newCirclePos.x = verts[(s+1)*3+0];
m_newCirclePos.y = verts[(s+1)*3+1];
m_newCirclePos.z = verts[(s+1)*3+2];
m_newCirclePos += ci::Vec3f(Pos);

vertsNew[(s+1)*3+0] = m_newCirclePos.x;
vertsNew[(s+1)*3+1] = m_newCirclePos.y;
vertsNew[(s+1)*3+2] = 0;

}

// Attach tentacles on specific vertices
for (int i=0; i<m_tentacle.size(); i++)
{
m_tentacle[i]->m_Nodes[0].x = vertsNew[(i+1)*3+0];
m_tentacle[i]->m_Nodes[0].y = vertsNew[(i+1)*3+1];
m_tentacle[i]->m_Nodes[0].z = vertsNew[(i+1)*3+2];
m_tentacle[i]->enforceConstraints(Vec2f(0,0),0,0,0,0);
}
glPointSize(10);
glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, vertsNew );
glDrawArrays( GL_POINTS, 0, segments + 2 );
glDisableClientState( GL_VERTEX_ARRAY );
delete [] verts;
delete [] vertsNew;
}
``````
-
-1 what have you tried already and why didn't it work? – Byte56 Apr 20 '12 at 14:10