[Kde-games-devel] Konquest - patch for distance function

Jeremy Wick jwickers at gmail.com
Sun May 20 06:26:41 CEST 2007


Hi,

Just my two cents but it is indeed sqrt(2) ~= 1.4, if it was sqrt(2)/2
it would be ~=0.7, so shorter that going from (0,0) to (0,1) which is
not right.

The distance between (a,b) and (c,d) is sqrt((a-c)^2 + (b-d)^2).
Pinaraf, where did you get the /2 ?


On 5/20/07, Gustavo Moura <gugario at gmail.com> wrote:
> Hey,
>
> I know there is probably some basic detail I'm overlooking....  But is
> there a specific reason for the /2 in the end of the distance
> function?  Isn't the distance between (0,0) and (1,1) sqrt(2)?
> Anyways, Konquest is great!  Keep up the good work!
>
> Gustavo
>
> On 5/19/07, Pinaraf <pinaraf at gmail.com> wrote:
> > The distance computation code in KDE4 is the following :
> >     Coordinate  diff = p1->sector()->coord() - p2->sector()->coord();
> >     return sqrt( double( ( diff.x() * diff.x() )
> >                          + ( diff.y() * diff.y() ) ) ) / 2;
> > And it's mathematically correct. The distance between two points is half the
> > square root of the sum of square differences... (hard to explain)
> > If you have two points, (0, 0) and (1, 1). The distance between them is
> > sqrt(2)/2
> > With your computation code, it's 1 ==> there is no difference between going
> > to (1,0), (0,1) and (1,1)

-- 
WICKERSHEIMER
Jérémy


More information about the kde-games-devel mailing list