Re: GnomeCanvasLine



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.

> 
> > 
> > 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.

Regrds,
Lauris Kaplinski






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