Re: GnomeCanvasLine



On Thu, 4 May 2000, Lauris Kaplinski wrote:

> 
> On Wed, 3 May 2000, Gustavo Joćo Alves Marques Carneiro wrote:
> 
> > > (width * width / 4.0)
> > > during ::update and compare this to
> > > (dx * dx + dy * dy)
> > > 
> > > If you really need distance, you can find smallest squared value and
> > > take square root of this once.
> > 
> >   No square roots please! :) I mean, calculating a square root each time
> > the pointer moves across the canvas is not a good idea.
> 
> This is already offtopic, but I have Cyrix MX manual handy, so:
> 
> instruction	cycles
> FSQRT		59-60
> FMUL		4-6
> FDIV		24-34
> FADD		4-7
> 
> And MX is not very modern processor. So generally square root is not much
> worse than division.

  Ok. I'm a bit convinced. But maybe one could use hypot where available,
which is a function that calculates srqt(dx*dx + dy*dy) in a faster way. I
think it's a GNU extension.

> 
> > 
> > > 
> > > Calculating line inclination is probably not much faster, and
> > > abovementioned algorithm generates visible errors with fat lines near 45
> > > degrees angle.
> > 
> >   I don't agree. With 45 degrees angle, dx is equal to dy -- there's no
> > error (if you just want to find out if a point is close to a line).
> 
> You get sqrt(2) times error of actual distance. So if you point is
> very close to border, it will be detected, as being outside.

  You're right, but that's not very important.

> 
> Regrds,
> Lauris Kaplinski
> 
> 

-- 
Gustavo J.A.M. Carneiro
[reinolinux.fe.up.pt/~ee96090]
                                       





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]