Skip to content

Possible wrong computation? #27

Open

Description

@jx5c

in QuadTreeRect.java file,

    double dx = ewdistance * ewdistance;
    double dy = nsdistance * nsdistance;
    double distanceSqr = dx * dx + dy * dy;
    return distanceSqr;

should the distanceSqr be dx+dy?

Activity

  1. dfdietrick commented on May 30, 2016

    @dfdietrick
    Contributor

    No, that's what the method is supposed to return. Note the javadoc comments on the algorithm, the distance squared is used consistently throughout. Are you seeing unusual results in how the quad tree is functioning?

    • Don
  2. jx5c commented on May 30, 2016

    @jx5c
    Author

    I did not see unusual results. I wanted to find some open-source Geographic applications for research purposes, and came across yours. I am reading and analyzing the source code.

    For this part, what I am thinking is that

       dx = ewdistance * ewdistance 
       dy = nsdistance * nsdistance;
    

    seem already squared, why do we have dx*dx?

       distanceSqr = dx * dx + dy * dy;  
    

    will make distanceSqr = ewdistance^4 + nsdistance^4. That seems different from the code in the old borderDistance function.

    Jian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions