PDA

View Full Version : Lathe profile (sweep profile)



ramako
11-14-2013, 07:46 AM
Greetings, I have to lathe a profile to form an object. Basically, from an initial set of points (I am testing it out with 2 right now), I have to rotate them N times around Y axis( vertical) to get more points, and then draw the object.

I manage to get the points, but I do not know how to calculate the Faces vector. Any help would be appreciated...

Code for calculating vertices.

void plyPuntos::crear_vertices(int N) {
std::vector<float>::iterator it;
vector <float> auxiliar;
float r;
int i=0;
int n_points=Vertices.size();
int maxvert=N*n_points;

for (it=Vertices.begin(); it!=Vertices.end(); it+=3) {
for (int i=0; i<N; i++){
r=sqrt(pow((*it),2) + pow(*(it+2),2));
auxiliar.push_back(r*cos(i*(2*PI/N)));
auxiliar.push_back(*(it+1));
auxiliar.push_back(r*sin(i*(2*PI/N)));

}
}
Vertices.insert(Vertices.end(),auxiliar.begin(),au xiliar.end());


//////CODE FOR CREATING FACES///////
for (int s=0; s<N-1; s++) {
for(int t=0;t<n_points-1; t++){
Caras.push_back((t+n_points+1+(s*n_points))%maxver t);
Caras.push_back((t+n_points+(s*n_points))%maxvert) ;
Caras.push_back((t+(s*n_points))%maxvert);
Caras.push_back((t+(s*n_points))%maxvert);
Caras.push_back((t+1+(s*n_points))%maxvert);
Caras.push_back((t+1+n_points+(s*n_points))%maxver t);
}
}


Faces dont seem to be calculated correctly...any help?