Dear all,
I've been learning OpenGL on and off for a few years now, trying out different things. I've typically never really concerned myself with the inner workings of the library but more on just using it and playing with the results.
I finally decided to learn it properly so to speak, and got myself the Red Book and started studying from there. My question relates to something mentioned in the book when drawing circles whereby if you were to define all the relevant vectors/vertices in that circle using a loop to get the coordinates through sinf/cosf, you have to be careful when finally computing:
Assuming i is the loop index and EDGES is the number of "divisions" you wish to have in that circle (e.g. EDGES = 36 means a circle has 36 unique points), when i = EDGES, the result will not be exactly 0.0f. It ultimately mentions that to prevent visual artifacts, to equate the final point and the first point, thereby avoiding any potential FP accuracy which is all fine and dandy. However, I am curious about the importance of including checks for the salient points whereby the result of a sine function would exactly equal 1.0f / -1.0f / 0.0f.
I've tried my best to explain this, though I'm not convinced I have to a sufficient degree. Eitherway, it is not a major issue, I am ultimately concerned with overdoing accuracy code that will slow down the loading portion for no real significant visual gains.
Thanks in advance for any help.
I've been learning OpenGL on and off for a few years now, trying out different things. I've typically never really concerned myself with the inner workings of the library but more on just using it and playing with the results.
I finally decided to learn it properly so to speak, and got myself the Red Book and started studying from there. My question relates to something mentioned in the book when drawing circles whereby if you were to define all the relevant vectors/vertices in that circle using a loop to get the coordinates through sinf/cosf, you have to be careful when finally computing:
Code:
x = sinf(2.0f * M_PI * float(i) / float(EDGES))
Assuming i is the loop index and EDGES is the number of "divisions" you wish to have in that circle (e.g. EDGES = 36 means a circle has 36 unique points), when i = EDGES, the result will not be exactly 0.0f. It ultimately mentions that to prevent visual artifacts, to equate the final point and the first point, thereby avoiding any potential FP accuracy which is all fine and dandy. However, I am curious about the importance of including checks for the salient points whereby the result of a sine function would exactly equal 1.0f / -1.0f / 0.0f.
I've tried my best to explain this, though I'm not convinced I have to a sufficient degree. Eitherway, it is not a major issue, I am ultimately concerned with overdoing accuracy code that will slow down the loading portion for no real significant visual gains.
Thanks in advance for any help.