# inserVertex recursively

hi…
i have a polyLine with two vertices strart and end. I want to insert a vertex insiede of this polyline. i thought to do by recursione: take the distance from start to end and divided it for 2 and insert the vertex at index 1.
this is the function,

``````void ofApp::addVertex(float _x, float _y, float _x1, float _y1, int _index)
``````

{

``````if(numVertex < 100){
float dist = ofDist(_x, _y, _x1, _y1);
float newPoint = dist/2;
cerchio.insertVertex(newPoint, y, 0, _index);

vector <ofVec3f> vertices = cerchio.getVertices();

for(int index = 1; index < vertices.size()-1; index++){

addVertex(_x, _y, newPoint, _y1,  ?);
addVertex(newPoint, _y, _x1, _y1, ?);
}
}
``````

}

have problem with indices. how i can switch the indices in to right position?

thanks

I
Guess it dependa how inserta vertex shifts the indices array. Ir could be índex and index +1 or index -1 and index. ( index=_index)

sorry but i have not understand your answer.
can yuo explain me another one?

thanks 