Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Using Trigonometry to draw concentric circles following a path

  1. #1
    Junior Member Newbie
    Join Date
    May 2012
    Posts
    1

    Using Trigonometry to draw concentric circles following a path

    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:

    Click image for larger version. 

Name:	circles.jpg 
Views:	21 
Size:	7.5 KB 
ID:	739

    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

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    736
    This is not as straightfoward as you may think checkout this library http://www.linas.org/gle/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •