0

there, I'm drawing a contour (in x,z plan) with opengl, then I want to know if a point is inside or outside of the contour. so I get the xmin, xmax, ymin et ymaxvalues of that contour ( right now is just a circle) then I add -delta to each min value, and +deltato each max value.

then I doing this :

for(GLfloat x=getXmin()-getDelta();x<=getXmax()+getDelta();x+=getDelta())
for(GLfloat y=getYmin()-getDelta();y<=getYmax()+getDelta();y+=getDelta()){
...
}

I would like to get this :

enter image description here

but I got this :

enter image description here

I don't want to be close of the contour, because I fear a day to have the contour so close, than I'll get errors when I'll do some calculus. Since the problem comes from floating values. To solve this I can just do

for(GLfloat x=getXmin()-getDelta();x<=getXmax()+2.*getDelta();x+=getDelta())
for(GLfloat y=getYmin()-getDelta();y<=getYmax()+2.*getDelta();y+=getDelta()){
...
}

(dat's how I got the first picture)

So, I would like to know if it's the good way to just make the maximum value bigger... To be honnest, when I was writing this piece of code, I thought that adding +delta will ensure to don't be close of the contour

for information :

getXmax() return the value 1.2,

getDelta() return the value 0.1

getXmin() return the value -0.699135

The Unholy Metal Machine
  • 1,093
  • 2
  • 17
  • 36
  • 1
    What you call "delta" is usually referred to as epsilon. You need to add +/- this value for tolerance if your test is for equality. Your question addresses a point being inside or outside of the circle, but actually fails to consider the third case, the point lies on the perimeter of the circle. That is where the epsilon test comes in handy, if you do not have enough precision to clearly identify a point as inside or outside, then classify it as **on** the circle. By the way, a good value of epsilon would usually be less than 0.001, increasing this value will probably do the opposite. – Andon M. Coleman Oct 26 '13 at 02:58
  • 1
    @AndonM.Coleman Idea agreed. However here I suppose the OP's `getDelta` is actually `getStep`, and in his presenting code there's no `epsilon` considered. The solution is to simply add an epsilon to the upper bound of that iteration. – starrify Oct 26 '13 at 04:45
  • starrify has right I didn't add an `epsilon` because I thought my `delta` would be able to work as an `epsilon` too. I didn't realize that in this case my delta will fall right on the `contour`... so I guess I will solve my problem by adding an `epsilon` – The Unholy Metal Machine Oct 26 '13 at 05:03

0 Answers0