Hey Guys!
First Post and hopefully an interesting problem - at least one I am trying to get my head around!
I have a small OpenGL application, which uses a series of 3D points to draw a line. I am trying to implement an algorithm that allow me to generate a tube from the line, by drawing a cirle of points around each vertex in my list of points. I have got my head around OpenGL for drawing the line and at each point drawing a circle of points, as shown:
[ATTACH=CONFIG]177[/ATTACH]
float angle = 6.283185307f / 15;
for (int j = 0; j<10; j++){ //Each point on the line
for (int j = 0; j< 15; j++){ //Each point on the circle
pX[pT] = 0 + (sin(angle * i));
pY[pT] = (0-(float)pointsY[j] + (cos(angle * i));
pZ[pT] = (0-(float)pointsX[j]);
}
pT++;
}
I am however struggling to extend this so that based on the previous point and the next point in the list from where I am, I perform a rotation so that the circle I draw is perpendicular to the line. I am trying to do this using trigonometry and I am sure that it must be relitively straightforward, I just can’t get my head around it today! Any suggestions or pointers are greatly appreciated.
Chris