How to effectively check whether a path is inside a series of bounding boxes?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












Given a series of interconnected rectangular bounding boxes,
and a path that is a described by a polynomial (or a polynomial spline),
how can I check whether the path is entirely inside the bounding boxes, precisely?
(as shown in the below figure)
Bounding boxes and path







share|cite|improve this question





















  • The curve only satisfies inequalities by function of box (line).
    – Takahiro Waki
    Jul 17 at 3:33










  • @TakahiroWaki, yes correct, and I am actually looking for a method that could effectively split the trajectory into multiple parts and perform the check on each individual of them. Currently, I perform a binary search, but I wonder is there any better method.
    – Nyaruko
    Jul 17 at 4:14














up vote
2
down vote

favorite












Given a series of interconnected rectangular bounding boxes,
and a path that is a described by a polynomial (or a polynomial spline),
how can I check whether the path is entirely inside the bounding boxes, precisely?
(as shown in the below figure)
Bounding boxes and path







share|cite|improve this question





















  • The curve only satisfies inequalities by function of box (line).
    – Takahiro Waki
    Jul 17 at 3:33










  • @TakahiroWaki, yes correct, and I am actually looking for a method that could effectively split the trajectory into multiple parts and perform the check on each individual of them. Currently, I perform a binary search, but I wonder is there any better method.
    – Nyaruko
    Jul 17 at 4:14












up vote
2
down vote

favorite









up vote
2
down vote

favorite











Given a series of interconnected rectangular bounding boxes,
and a path that is a described by a polynomial (or a polynomial spline),
how can I check whether the path is entirely inside the bounding boxes, precisely?
(as shown in the below figure)
Bounding boxes and path







share|cite|improve this question













Given a series of interconnected rectangular bounding boxes,
and a path that is a described by a polynomial (or a polynomial spline),
how can I check whether the path is entirely inside the bounding boxes, precisely?
(as shown in the below figure)
Bounding boxes and path









share|cite|improve this question












share|cite|improve this question




share|cite|improve this question








edited Jul 21 at 5:02









Parcly Taxel

33.6k136588




33.6k136588









asked Jul 17 at 2:50









Nyaruko

1185




1185











  • The curve only satisfies inequalities by function of box (line).
    – Takahiro Waki
    Jul 17 at 3:33










  • @TakahiroWaki, yes correct, and I am actually looking for a method that could effectively split the trajectory into multiple parts and perform the check on each individual of them. Currently, I perform a binary search, but I wonder is there any better method.
    – Nyaruko
    Jul 17 at 4:14
















  • The curve only satisfies inequalities by function of box (line).
    – Takahiro Waki
    Jul 17 at 3:33










  • @TakahiroWaki, yes correct, and I am actually looking for a method that could effectively split the trajectory into multiple parts and perform the check on each individual of them. Currently, I perform a binary search, but I wonder is there any better method.
    – Nyaruko
    Jul 17 at 4:14















The curve only satisfies inequalities by function of box (line).
– Takahiro Waki
Jul 17 at 3:33




The curve only satisfies inequalities by function of box (line).
– Takahiro Waki
Jul 17 at 3:33












@TakahiroWaki, yes correct, and I am actually looking for a method that could effectively split the trajectory into multiple parts and perform the check on each individual of them. Currently, I perform a binary search, but I wonder is there any better method.
– Nyaruko
Jul 17 at 4:14




@TakahiroWaki, yes correct, and I am actually looking for a method that could effectively split the trajectory into multiple parts and perform the check on each individual of them. Currently, I perform a binary search, but I wonder is there any better method.
– Nyaruko
Jul 17 at 4:14










2 Answers
2






active

oldest

votes

















up vote
3
down vote



accepted










Let the curves in the spline be given by parametric expressions $(x(t),y(t))$ with $0le tle1$ as is common in computer graphics.



Consider each pair of curve and rectangle in turn. For the four edges of that rectangle, determine all $t$-values on the curve that correspond to intersections, of which there may be none. This is relatively simple to accomplish by rotating the edge onto an axis and finding roots of the component polynomials of the resulting curve, as detailed for example here.



Then determine if $t=0$ on the curve is in the rectangle; from there mark the found intersection $t$-parameters as entering or exiting the rectangle alternately. This gives a subset of $[0,1]$ corresponding to that part of the curve within the rectangle. For a given curve, take the union of said subsets arising from its pairings with all rectangles; it lies entirely within the bounding boxes if the union is the whole interval $[0,1]$.



The entire spline is then inside the bounding boxes if each of its component curves is.






share|cite|improve this answer






























    up vote
    3
    down vote













    Another answer has already suggested a specific algorithm, so I won't go into too many details on that. I think it's worth mentioning, though, that there are two properties of splines that you can put to use for this:



    • A spline is a parametrized convex combination of its control points, and is thus contained in their convex hull.

    • A spline can be efficiently subdivided into shorter splines of the same type.

    Together, these allow for a recursive algorithm to check whether a spline is contained in a convex area (e.g. a rectangle): If an endpoint is outside the area, it isn't. If all control points are inside the area, it is. If neither is the case, subdivide and recursively apply the algorithm to the components.



    You can find more on these properties at this SO question and the links provided there.






    share|cite|improve this answer





















      Your Answer




      StackExchange.ifUsing("editor", function ()
      return StackExchange.using("mathjaxEditing", function ()
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
      );
      );
      , "mathjax-editing");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "69"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      noCode: true, onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );








       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2854090%2fhow-to-effectively-check-whether-a-path-is-inside-a-series-of-bounding-boxes%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      3
      down vote



      accepted










      Let the curves in the spline be given by parametric expressions $(x(t),y(t))$ with $0le tle1$ as is common in computer graphics.



      Consider each pair of curve and rectangle in turn. For the four edges of that rectangle, determine all $t$-values on the curve that correspond to intersections, of which there may be none. This is relatively simple to accomplish by rotating the edge onto an axis and finding roots of the component polynomials of the resulting curve, as detailed for example here.



      Then determine if $t=0$ on the curve is in the rectangle; from there mark the found intersection $t$-parameters as entering or exiting the rectangle alternately. This gives a subset of $[0,1]$ corresponding to that part of the curve within the rectangle. For a given curve, take the union of said subsets arising from its pairings with all rectangles; it lies entirely within the bounding boxes if the union is the whole interval $[0,1]$.



      The entire spline is then inside the bounding boxes if each of its component curves is.






      share|cite|improve this answer



























        up vote
        3
        down vote



        accepted










        Let the curves in the spline be given by parametric expressions $(x(t),y(t))$ with $0le tle1$ as is common in computer graphics.



        Consider each pair of curve and rectangle in turn. For the four edges of that rectangle, determine all $t$-values on the curve that correspond to intersections, of which there may be none. This is relatively simple to accomplish by rotating the edge onto an axis and finding roots of the component polynomials of the resulting curve, as detailed for example here.



        Then determine if $t=0$ on the curve is in the rectangle; from there mark the found intersection $t$-parameters as entering or exiting the rectangle alternately. This gives a subset of $[0,1]$ corresponding to that part of the curve within the rectangle. For a given curve, take the union of said subsets arising from its pairings with all rectangles; it lies entirely within the bounding boxes if the union is the whole interval $[0,1]$.



        The entire spline is then inside the bounding boxes if each of its component curves is.






        share|cite|improve this answer

























          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          Let the curves in the spline be given by parametric expressions $(x(t),y(t))$ with $0le tle1$ as is common in computer graphics.



          Consider each pair of curve and rectangle in turn. For the four edges of that rectangle, determine all $t$-values on the curve that correspond to intersections, of which there may be none. This is relatively simple to accomplish by rotating the edge onto an axis and finding roots of the component polynomials of the resulting curve, as detailed for example here.



          Then determine if $t=0$ on the curve is in the rectangle; from there mark the found intersection $t$-parameters as entering or exiting the rectangle alternately. This gives a subset of $[0,1]$ corresponding to that part of the curve within the rectangle. For a given curve, take the union of said subsets arising from its pairings with all rectangles; it lies entirely within the bounding boxes if the union is the whole interval $[0,1]$.



          The entire spline is then inside the bounding boxes if each of its component curves is.






          share|cite|improve this answer















          Let the curves in the spline be given by parametric expressions $(x(t),y(t))$ with $0le tle1$ as is common in computer graphics.



          Consider each pair of curve and rectangle in turn. For the four edges of that rectangle, determine all $t$-values on the curve that correspond to intersections, of which there may be none. This is relatively simple to accomplish by rotating the edge onto an axis and finding roots of the component polynomials of the resulting curve, as detailed for example here.



          Then determine if $t=0$ on the curve is in the rectangle; from there mark the found intersection $t$-parameters as entering or exiting the rectangle alternately. This gives a subset of $[0,1]$ corresponding to that part of the curve within the rectangle. For a given curve, take the union of said subsets arising from its pairings with all rectangles; it lies entirely within the bounding boxes if the union is the whole interval $[0,1]$.



          The entire spline is then inside the bounding boxes if each of its component curves is.







          share|cite|improve this answer















          share|cite|improve this answer



          share|cite|improve this answer








          edited Jul 17 at 6:28


























          answered Jul 17 at 5:18









          Parcly Taxel

          33.6k136588




          33.6k136588




















              up vote
              3
              down vote













              Another answer has already suggested a specific algorithm, so I won't go into too many details on that. I think it's worth mentioning, though, that there are two properties of splines that you can put to use for this:



              • A spline is a parametrized convex combination of its control points, and is thus contained in their convex hull.

              • A spline can be efficiently subdivided into shorter splines of the same type.

              Together, these allow for a recursive algorithm to check whether a spline is contained in a convex area (e.g. a rectangle): If an endpoint is outside the area, it isn't. If all control points are inside the area, it is. If neither is the case, subdivide and recursively apply the algorithm to the components.



              You can find more on these properties at this SO question and the links provided there.






              share|cite|improve this answer

























                up vote
                3
                down vote













                Another answer has already suggested a specific algorithm, so I won't go into too many details on that. I think it's worth mentioning, though, that there are two properties of splines that you can put to use for this:



                • A spline is a parametrized convex combination of its control points, and is thus contained in their convex hull.

                • A spline can be efficiently subdivided into shorter splines of the same type.

                Together, these allow for a recursive algorithm to check whether a spline is contained in a convex area (e.g. a rectangle): If an endpoint is outside the area, it isn't. If all control points are inside the area, it is. If neither is the case, subdivide and recursively apply the algorithm to the components.



                You can find more on these properties at this SO question and the links provided there.






                share|cite|improve this answer























                  up vote
                  3
                  down vote










                  up vote
                  3
                  down vote









                  Another answer has already suggested a specific algorithm, so I won't go into too many details on that. I think it's worth mentioning, though, that there are two properties of splines that you can put to use for this:



                  • A spline is a parametrized convex combination of its control points, and is thus contained in their convex hull.

                  • A spline can be efficiently subdivided into shorter splines of the same type.

                  Together, these allow for a recursive algorithm to check whether a spline is contained in a convex area (e.g. a rectangle): If an endpoint is outside the area, it isn't. If all control points are inside the area, it is. If neither is the case, subdivide and recursively apply the algorithm to the components.



                  You can find more on these properties at this SO question and the links provided there.






                  share|cite|improve this answer













                  Another answer has already suggested a specific algorithm, so I won't go into too many details on that. I think it's worth mentioning, though, that there are two properties of splines that you can put to use for this:



                  • A spline is a parametrized convex combination of its control points, and is thus contained in their convex hull.

                  • A spline can be efficiently subdivided into shorter splines of the same type.

                  Together, these allow for a recursive algorithm to check whether a spline is contained in a convex area (e.g. a rectangle): If an endpoint is outside the area, it isn't. If all control points are inside the area, it is. If neither is the case, subdivide and recursively apply the algorithm to the components.



                  You can find more on these properties at this SO question and the links provided there.







                  share|cite|improve this answer













                  share|cite|improve this answer



                  share|cite|improve this answer











                  answered Jul 17 at 5:36









                  joriki

                  164k10180328




                  164k10180328






















                       

                      draft saved


                      draft discarded


























                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2854090%2fhow-to-effectively-check-whether-a-path-is-inside-a-series-of-bounding-boxes%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      What is the equation of a 3D cone with generalised tilt?

                      Color the edges and diagonals of a regular polygon

                      Relationship between determinant of matrix and determinant of adjoint?