1

I have been searching the internet for about a day and I can not seem to find an algorithm to find all points within a bounding box.

Picture:

The accuracy also needs to be 8 decimal digits long.

Example: (0,0) (0,0.00000001) (0,0.00000002) etc.. (80,80.45356433)

8
  • 1
    What exactly is the question? You can iterate over all points at any level of accuracy. Commented Nov 29, 2013 at 23:07
  • What are you trying to do? maybe it's another way to implement what you want? Commented Nov 29, 2013 at 23:07
  • Like Simeon Visser said. iterate over all points withing a bouding box Commented Nov 29, 2013 at 23:08
  • What do you have so far? Do you want to print the points on the screen or write to a file? Commented Nov 29, 2013 at 23:14
  • What sort of coordinate system are these corners in? I tried counting how many "points" there are in there, with a granularity of 100 million ppu, but I can't work out the width and height. Commented Nov 29, 2013 at 23:23

2 Answers 2

1

I don't know what exactly you mean by finding all points inside a box. There is just too many!

I would suggest using an Identifier function, i.e., given a point (x, y), I(x, y) = 1 if and only if the point (x, y) is inside your box.

A call to the identifier in your example requires $4$ comparisons.

    public class Box {
          /**
           * Identifier function.
           * @param x  x-coordinate of input point
           * @param y  y-coordinate of input point
           * @return True if and only if the given point is inside the box.
           */
          public boolean IsInside(double x, double y) {
              return (this.x_min <= x) && (this.x_max >= x) &&
                     (this.y_max >= y) && (this.y_min <= y);
           }
          double x_min, x_max, y_min, y_max; // or do it with left top width and height 
     }   

I hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

0
    long p = (long)Math.pow(10, 8);
    long start = 90 * p;
    long end = 180 * p;
    for (long i = start; i < end; i++) {
        for (long j = start; j < end; j++) {
            System.out.println("(" + (double)i / p + "," + (double)j / p + ")");
        }
    }

will take a while

1 Comment

instead of doubles, it is better to use longs -- it'd be faster and more precise

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.