How to get a rectangle around a polygon?

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











up vote
-1
down vote

favorite












I have a polygon with all coordinates known. I want to draw a rectangle around it making $(x_1,y_1)$ and $(x_2,y_2)$ as it's base. How can I get new coordinates forming rectangle around polygon?
polygon



(x1,y1) = (8.375, 127.5258)
(x2,y2) = (26.1326, 127.5258)
(x3,y3) = (26.375, 130.5258)
(x4,y4) = (23.6995, 141.2277)
(x5,y5) = (8.375, 137.3966)






share|cite|improve this question





















  • Now, what do you think about the problem?
    – Parcly Taxel
    Jul 18 at 11:33










  • How to create a rectangle with the values I have and forming with new coordinates for it.
    – Alex Dave
    Jul 18 at 11:35










  • Do you want all vertices of the polygon to touch the rectangle?
    – Zeekless
    Jul 18 at 11:39











  • yes, all the vertices need to touch rectangle.
    – Alex Dave
    Jul 18 at 11:40










  • @AlexDave, it is impossible in general. Consider a polygon with vertices $(0,0), (1,0), (0,1), (0.75,0.75)$.
    – Zeekless
    Jul 18 at 11:42














up vote
-1
down vote

favorite












I have a polygon with all coordinates known. I want to draw a rectangle around it making $(x_1,y_1)$ and $(x_2,y_2)$ as it's base. How can I get new coordinates forming rectangle around polygon?
polygon



(x1,y1) = (8.375, 127.5258)
(x2,y2) = (26.1326, 127.5258)
(x3,y3) = (26.375, 130.5258)
(x4,y4) = (23.6995, 141.2277)
(x5,y5) = (8.375, 137.3966)






share|cite|improve this question





















  • Now, what do you think about the problem?
    – Parcly Taxel
    Jul 18 at 11:33










  • How to create a rectangle with the values I have and forming with new coordinates for it.
    – Alex Dave
    Jul 18 at 11:35










  • Do you want all vertices of the polygon to touch the rectangle?
    – Zeekless
    Jul 18 at 11:39











  • yes, all the vertices need to touch rectangle.
    – Alex Dave
    Jul 18 at 11:40










  • @AlexDave, it is impossible in general. Consider a polygon with vertices $(0,0), (1,0), (0,1), (0.75,0.75)$.
    – Zeekless
    Jul 18 at 11:42












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have a polygon with all coordinates known. I want to draw a rectangle around it making $(x_1,y_1)$ and $(x_2,y_2)$ as it's base. How can I get new coordinates forming rectangle around polygon?
polygon



(x1,y1) = (8.375, 127.5258)
(x2,y2) = (26.1326, 127.5258)
(x3,y3) = (26.375, 130.5258)
(x4,y4) = (23.6995, 141.2277)
(x5,y5) = (8.375, 137.3966)






share|cite|improve this question













I have a polygon with all coordinates known. I want to draw a rectangle around it making $(x_1,y_1)$ and $(x_2,y_2)$ as it's base. How can I get new coordinates forming rectangle around polygon?
polygon



(x1,y1) = (8.375, 127.5258)
(x2,y2) = (26.1326, 127.5258)
(x3,y3) = (26.375, 130.5258)
(x4,y4) = (23.6995, 141.2277)
(x5,y5) = (8.375, 137.3966)








share|cite|improve this question












share|cite|improve this question




share|cite|improve this question








edited Jul 18 at 11:41
























asked Jul 18 at 11:31









Alex Dave

95




95











  • Now, what do you think about the problem?
    – Parcly Taxel
    Jul 18 at 11:33










  • How to create a rectangle with the values I have and forming with new coordinates for it.
    – Alex Dave
    Jul 18 at 11:35










  • Do you want all vertices of the polygon to touch the rectangle?
    – Zeekless
    Jul 18 at 11:39











  • yes, all the vertices need to touch rectangle.
    – Alex Dave
    Jul 18 at 11:40










  • @AlexDave, it is impossible in general. Consider a polygon with vertices $(0,0), (1,0), (0,1), (0.75,0.75)$.
    – Zeekless
    Jul 18 at 11:42
















  • Now, what do you think about the problem?
    – Parcly Taxel
    Jul 18 at 11:33










  • How to create a rectangle with the values I have and forming with new coordinates for it.
    – Alex Dave
    Jul 18 at 11:35










  • Do you want all vertices of the polygon to touch the rectangle?
    – Zeekless
    Jul 18 at 11:39











  • yes, all the vertices need to touch rectangle.
    – Alex Dave
    Jul 18 at 11:40










  • @AlexDave, it is impossible in general. Consider a polygon with vertices $(0,0), (1,0), (0,1), (0.75,0.75)$.
    – Zeekless
    Jul 18 at 11:42















Now, what do you think about the problem?
– Parcly Taxel
Jul 18 at 11:33




Now, what do you think about the problem?
– Parcly Taxel
Jul 18 at 11:33












How to create a rectangle with the values I have and forming with new coordinates for it.
– Alex Dave
Jul 18 at 11:35




How to create a rectangle with the values I have and forming with new coordinates for it.
– Alex Dave
Jul 18 at 11:35












Do you want all vertices of the polygon to touch the rectangle?
– Zeekless
Jul 18 at 11:39





Do you want all vertices of the polygon to touch the rectangle?
– Zeekless
Jul 18 at 11:39













yes, all the vertices need to touch rectangle.
– Alex Dave
Jul 18 at 11:40




yes, all the vertices need to touch rectangle.
– Alex Dave
Jul 18 at 11:40












@AlexDave, it is impossible in general. Consider a polygon with vertices $(0,0), (1,0), (0,1), (0.75,0.75)$.
– Zeekless
Jul 18 at 11:42




@AlexDave, it is impossible in general. Consider a polygon with vertices $(0,0), (1,0), (0,1), (0.75,0.75)$.
– Zeekless
Jul 18 at 11:42










3 Answers
3






active

oldest

votes

















up vote
2
down vote













Rotate the figure by angle $-arctandfracy_2-y_1x_2-x_1$ so that the side $12$ becomes horizontal, and determine the axis-aligned bounding box (which is trivial).



Then rotate the four corners back in place (if needed).



enter image description here



enter image description here






share|cite|improve this answer























  • can you please tell me the new coordinates of rectangle for the values which I have given! I implemented in the formula but I am not sure of the exact coordinates. Please elaborate your answer with values.
    – Alex Dave
    Jul 18 at 13:21











  • @AlexDave: sorry, no, this is not a free problem resolution service. Check graphically.
    – Yves Daoust
    Jul 18 at 13:25











  • @AlexDave, my answer gives you the exact formulas.
    – Zeekless
    Jul 18 at 13:31


















up vote
0
down vote













This can be done by fixing the direction of a side of the rectangle in any way (it need not be one of the sides of the polygon).



So let $(x_1, y_1), ..., (x_n, y_n)$ be the vertices of the polygon, and let $(a,b)$ be a vector which is parallel to a side of the desired rectangle.



You need to find the line equation of the sides of the rectangle.
As $(a,b)$ is a normal to two of them and parallel to the other two, two of the line equations have the form:



$$ax+by+c=0$$



and the other two have the form:



$$bx-ay+c=0$$.



I show you how to find the first two, the other two is analogous ($c$ is the unknown). Let $ell$ be the line that consists of the endpoints of the multiples of the vector $(a,b)$. So $ell$ consists of the points $(at, bt)$, $tin mathbbR$.



So we are looking for two line equations of the form $ax+by+c=0$, with $c$ being unknown. By altering $c$, we are shifting a line perpendicular to the vector $(a,b)$. The projection of the polygon to the line $ell$ is a segment, and the extreme positions where the shifted line touches the polygon are those vertices of the polygon whose projection to $ell$ are the endpoints of this segment.
So you are looking for the vertices $(x_i, y_i)$ such that the projection of $(x_i, y_i)$ to $ell$ are "leftmost" and "rightmost" on $ell$, that is, $ax_i+by_i$ are minimal or maximal. (The projections to $ell$ are the points corresponding to the scalar product if you view $ell$ as the real line.) So find i such that $ax_i+by_i$ is minimal, and let this minimum be $c_1$. Also find i such that $ax_i+by_i$ is maximal, and let this maximum be $c_2$. Then the two line equations we were looking for are $ax+by-c_1=0$ and $ax+by-c_2=0$.






share|cite|improve this answer




























    up vote
    -1
    down vote













    I will denote $v_ij=beginbmatrix x_j \ y_j endbmatrix - beginbmatrix x_i \ y_i endbmatrix$, that is the vector from $i$-point to $j$-point.



    $$
    beginbmatrix x_2 \ y_2 endbmatrix +fracv_12 cdot v_23Vertv_12Vert Big(fracv_12Vertv_12VertBig) = text coordinates of lower-right vertex.
    $$



    $$
    beginbmatrix x_1 \ y_1 endbmatrix +fracv_12 cdot v_15Vertv_12Vert Big(fracv_12Vertv_12VertBig)= text coordinates of lower-left vertex.
    $$



    $$
    beginbmatrix x_4 \ y_4 endbmatrix +fracv_12 cdot v_43Vertv_12VertBig(fracv_12Vertv_12VertBig) = text coordinates of upper-right vertex.
    $$



    $$
    beginbmatrix x_4 \ y_4 endbmatrix +fracv_12 cdot v_45Vertv_12Vert Big(fracv_12Vertv_12VertBig)= text coordinates of upper-left vertex.
    $$



    Fractions like $fracv_12 cdot v_45Vertv_12Vert$ are the projections of sides of the polygon onto the direction of the base, while $Big(fracv_12Vertv_12VertBig)$ is a unit vector of the base direction.






    share|cite|improve this answer























    • Now what if the polygon has six vertices ?
      – Yves Daoust
      Jul 18 at 12:37










    • @YvesDaoust, general answer is that the problem may be unsolvable (see my comment to the original question). That is why I am giving a solution to this particular case.
      – Zeekless
      Jul 18 at 12:37










    • Unsolvable ? No, it is always solvable, unless there are vertices on either sides of $12$.
      – Yves Daoust
      Jul 18 at 12:38







    • 1




      Mh, I am not convinced that the OP understood this in the general case. But we can't know. Anyway, it is easy to solve the problem without that constraint, or to check that the constraint is achievable.
      – Yves Daoust
      Jul 18 at 12:41







    • 1




      It is pretty ad-hoc, when a general solution is not much more complicated.
      – Yves Daoust
      Jul 18 at 12:44










    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%2f2855493%2fhow-to-get-a-rectangle-around-a-polygon%23new-answer', 'question_page');

    );

    Post as a guest






























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    Rotate the figure by angle $-arctandfracy_2-y_1x_2-x_1$ so that the side $12$ becomes horizontal, and determine the axis-aligned bounding box (which is trivial).



    Then rotate the four corners back in place (if needed).



    enter image description here



    enter image description here






    share|cite|improve this answer























    • can you please tell me the new coordinates of rectangle for the values which I have given! I implemented in the formula but I am not sure of the exact coordinates. Please elaborate your answer with values.
      – Alex Dave
      Jul 18 at 13:21











    • @AlexDave: sorry, no, this is not a free problem resolution service. Check graphically.
      – Yves Daoust
      Jul 18 at 13:25











    • @AlexDave, my answer gives you the exact formulas.
      – Zeekless
      Jul 18 at 13:31















    up vote
    2
    down vote













    Rotate the figure by angle $-arctandfracy_2-y_1x_2-x_1$ so that the side $12$ becomes horizontal, and determine the axis-aligned bounding box (which is trivial).



    Then rotate the four corners back in place (if needed).



    enter image description here



    enter image description here






    share|cite|improve this answer























    • can you please tell me the new coordinates of rectangle for the values which I have given! I implemented in the formula but I am not sure of the exact coordinates. Please elaborate your answer with values.
      – Alex Dave
      Jul 18 at 13:21











    • @AlexDave: sorry, no, this is not a free problem resolution service. Check graphically.
      – Yves Daoust
      Jul 18 at 13:25











    • @AlexDave, my answer gives you the exact formulas.
      – Zeekless
      Jul 18 at 13:31













    up vote
    2
    down vote










    up vote
    2
    down vote









    Rotate the figure by angle $-arctandfracy_2-y_1x_2-x_1$ so that the side $12$ becomes horizontal, and determine the axis-aligned bounding box (which is trivial).



    Then rotate the four corners back in place (if needed).



    enter image description here



    enter image description here






    share|cite|improve this answer















    Rotate the figure by angle $-arctandfracy_2-y_1x_2-x_1$ so that the side $12$ becomes horizontal, and determine the axis-aligned bounding box (which is trivial).



    Then rotate the four corners back in place (if needed).



    enter image description here



    enter image description here







    share|cite|improve this answer















    share|cite|improve this answer



    share|cite|improve this answer








    edited Jul 18 at 12:24


























    answered Jul 18 at 12:06









    Yves Daoust

    111k665204




    111k665204











    • can you please tell me the new coordinates of rectangle for the values which I have given! I implemented in the formula but I am not sure of the exact coordinates. Please elaborate your answer with values.
      – Alex Dave
      Jul 18 at 13:21











    • @AlexDave: sorry, no, this is not a free problem resolution service. Check graphically.
      – Yves Daoust
      Jul 18 at 13:25











    • @AlexDave, my answer gives you the exact formulas.
      – Zeekless
      Jul 18 at 13:31

















    • can you please tell me the new coordinates of rectangle for the values which I have given! I implemented in the formula but I am not sure of the exact coordinates. Please elaborate your answer with values.
      – Alex Dave
      Jul 18 at 13:21











    • @AlexDave: sorry, no, this is not a free problem resolution service. Check graphically.
      – Yves Daoust
      Jul 18 at 13:25











    • @AlexDave, my answer gives you the exact formulas.
      – Zeekless
      Jul 18 at 13:31
















    can you please tell me the new coordinates of rectangle for the values which I have given! I implemented in the formula but I am not sure of the exact coordinates. Please elaborate your answer with values.
    – Alex Dave
    Jul 18 at 13:21





    can you please tell me the new coordinates of rectangle for the values which I have given! I implemented in the formula but I am not sure of the exact coordinates. Please elaborate your answer with values.
    – Alex Dave
    Jul 18 at 13:21













    @AlexDave: sorry, no, this is not a free problem resolution service. Check graphically.
    – Yves Daoust
    Jul 18 at 13:25





    @AlexDave: sorry, no, this is not a free problem resolution service. Check graphically.
    – Yves Daoust
    Jul 18 at 13:25













    @AlexDave, my answer gives you the exact formulas.
    – Zeekless
    Jul 18 at 13:31





    @AlexDave, my answer gives you the exact formulas.
    – Zeekless
    Jul 18 at 13:31











    up vote
    0
    down vote













    This can be done by fixing the direction of a side of the rectangle in any way (it need not be one of the sides of the polygon).



    So let $(x_1, y_1), ..., (x_n, y_n)$ be the vertices of the polygon, and let $(a,b)$ be a vector which is parallel to a side of the desired rectangle.



    You need to find the line equation of the sides of the rectangle.
    As $(a,b)$ is a normal to two of them and parallel to the other two, two of the line equations have the form:



    $$ax+by+c=0$$



    and the other two have the form:



    $$bx-ay+c=0$$.



    I show you how to find the first two, the other two is analogous ($c$ is the unknown). Let $ell$ be the line that consists of the endpoints of the multiples of the vector $(a,b)$. So $ell$ consists of the points $(at, bt)$, $tin mathbbR$.



    So we are looking for two line equations of the form $ax+by+c=0$, with $c$ being unknown. By altering $c$, we are shifting a line perpendicular to the vector $(a,b)$. The projection of the polygon to the line $ell$ is a segment, and the extreme positions where the shifted line touches the polygon are those vertices of the polygon whose projection to $ell$ are the endpoints of this segment.
    So you are looking for the vertices $(x_i, y_i)$ such that the projection of $(x_i, y_i)$ to $ell$ are "leftmost" and "rightmost" on $ell$, that is, $ax_i+by_i$ are minimal or maximal. (The projections to $ell$ are the points corresponding to the scalar product if you view $ell$ as the real line.) So find i such that $ax_i+by_i$ is minimal, and let this minimum be $c_1$. Also find i such that $ax_i+by_i$ is maximal, and let this maximum be $c_2$. Then the two line equations we were looking for are $ax+by-c_1=0$ and $ax+by-c_2=0$.






    share|cite|improve this answer

























      up vote
      0
      down vote













      This can be done by fixing the direction of a side of the rectangle in any way (it need not be one of the sides of the polygon).



      So let $(x_1, y_1), ..., (x_n, y_n)$ be the vertices of the polygon, and let $(a,b)$ be a vector which is parallel to a side of the desired rectangle.



      You need to find the line equation of the sides of the rectangle.
      As $(a,b)$ is a normal to two of them and parallel to the other two, two of the line equations have the form:



      $$ax+by+c=0$$



      and the other two have the form:



      $$bx-ay+c=0$$.



      I show you how to find the first two, the other two is analogous ($c$ is the unknown). Let $ell$ be the line that consists of the endpoints of the multiples of the vector $(a,b)$. So $ell$ consists of the points $(at, bt)$, $tin mathbbR$.



      So we are looking for two line equations of the form $ax+by+c=0$, with $c$ being unknown. By altering $c$, we are shifting a line perpendicular to the vector $(a,b)$. The projection of the polygon to the line $ell$ is a segment, and the extreme positions where the shifted line touches the polygon are those vertices of the polygon whose projection to $ell$ are the endpoints of this segment.
      So you are looking for the vertices $(x_i, y_i)$ such that the projection of $(x_i, y_i)$ to $ell$ are "leftmost" and "rightmost" on $ell$, that is, $ax_i+by_i$ are minimal or maximal. (The projections to $ell$ are the points corresponding to the scalar product if you view $ell$ as the real line.) So find i such that $ax_i+by_i$ is minimal, and let this minimum be $c_1$. Also find i such that $ax_i+by_i$ is maximal, and let this maximum be $c_2$. Then the two line equations we were looking for are $ax+by-c_1=0$ and $ax+by-c_2=0$.






      share|cite|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        This can be done by fixing the direction of a side of the rectangle in any way (it need not be one of the sides of the polygon).



        So let $(x_1, y_1), ..., (x_n, y_n)$ be the vertices of the polygon, and let $(a,b)$ be a vector which is parallel to a side of the desired rectangle.



        You need to find the line equation of the sides of the rectangle.
        As $(a,b)$ is a normal to two of them and parallel to the other two, two of the line equations have the form:



        $$ax+by+c=0$$



        and the other two have the form:



        $$bx-ay+c=0$$.



        I show you how to find the first two, the other two is analogous ($c$ is the unknown). Let $ell$ be the line that consists of the endpoints of the multiples of the vector $(a,b)$. So $ell$ consists of the points $(at, bt)$, $tin mathbbR$.



        So we are looking for two line equations of the form $ax+by+c=0$, with $c$ being unknown. By altering $c$, we are shifting a line perpendicular to the vector $(a,b)$. The projection of the polygon to the line $ell$ is a segment, and the extreme positions where the shifted line touches the polygon are those vertices of the polygon whose projection to $ell$ are the endpoints of this segment.
        So you are looking for the vertices $(x_i, y_i)$ such that the projection of $(x_i, y_i)$ to $ell$ are "leftmost" and "rightmost" on $ell$, that is, $ax_i+by_i$ are minimal or maximal. (The projections to $ell$ are the points corresponding to the scalar product if you view $ell$ as the real line.) So find i such that $ax_i+by_i$ is minimal, and let this minimum be $c_1$. Also find i such that $ax_i+by_i$ is maximal, and let this maximum be $c_2$. Then the two line equations we were looking for are $ax+by-c_1=0$ and $ax+by-c_2=0$.






        share|cite|improve this answer













        This can be done by fixing the direction of a side of the rectangle in any way (it need not be one of the sides of the polygon).



        So let $(x_1, y_1), ..., (x_n, y_n)$ be the vertices of the polygon, and let $(a,b)$ be a vector which is parallel to a side of the desired rectangle.



        You need to find the line equation of the sides of the rectangle.
        As $(a,b)$ is a normal to two of them and parallel to the other two, two of the line equations have the form:



        $$ax+by+c=0$$



        and the other two have the form:



        $$bx-ay+c=0$$.



        I show you how to find the first two, the other two is analogous ($c$ is the unknown). Let $ell$ be the line that consists of the endpoints of the multiples of the vector $(a,b)$. So $ell$ consists of the points $(at, bt)$, $tin mathbbR$.



        So we are looking for two line equations of the form $ax+by+c=0$, with $c$ being unknown. By altering $c$, we are shifting a line perpendicular to the vector $(a,b)$. The projection of the polygon to the line $ell$ is a segment, and the extreme positions where the shifted line touches the polygon are those vertices of the polygon whose projection to $ell$ are the endpoints of this segment.
        So you are looking for the vertices $(x_i, y_i)$ such that the projection of $(x_i, y_i)$ to $ell$ are "leftmost" and "rightmost" on $ell$, that is, $ax_i+by_i$ are minimal or maximal. (The projections to $ell$ are the points corresponding to the scalar product if you view $ell$ as the real line.) So find i such that $ax_i+by_i$ is minimal, and let this minimum be $c_1$. Also find i such that $ax_i+by_i$ is maximal, and let this maximum be $c_2$. Then the two line equations we were looking for are $ax+by-c_1=0$ and $ax+by-c_2=0$.







        share|cite|improve this answer













        share|cite|improve this answer



        share|cite|improve this answer











        answered Jul 18 at 12:12









        A. Pongrácz

        2,574321




        2,574321




















            up vote
            -1
            down vote













            I will denote $v_ij=beginbmatrix x_j \ y_j endbmatrix - beginbmatrix x_i \ y_i endbmatrix$, that is the vector from $i$-point to $j$-point.



            $$
            beginbmatrix x_2 \ y_2 endbmatrix +fracv_12 cdot v_23Vertv_12Vert Big(fracv_12Vertv_12VertBig) = text coordinates of lower-right vertex.
            $$



            $$
            beginbmatrix x_1 \ y_1 endbmatrix +fracv_12 cdot v_15Vertv_12Vert Big(fracv_12Vertv_12VertBig)= text coordinates of lower-left vertex.
            $$



            $$
            beginbmatrix x_4 \ y_4 endbmatrix +fracv_12 cdot v_43Vertv_12VertBig(fracv_12Vertv_12VertBig) = text coordinates of upper-right vertex.
            $$



            $$
            beginbmatrix x_4 \ y_4 endbmatrix +fracv_12 cdot v_45Vertv_12Vert Big(fracv_12Vertv_12VertBig)= text coordinates of upper-left vertex.
            $$



            Fractions like $fracv_12 cdot v_45Vertv_12Vert$ are the projections of sides of the polygon onto the direction of the base, while $Big(fracv_12Vertv_12VertBig)$ is a unit vector of the base direction.






            share|cite|improve this answer























            • Now what if the polygon has six vertices ?
              – Yves Daoust
              Jul 18 at 12:37










            • @YvesDaoust, general answer is that the problem may be unsolvable (see my comment to the original question). That is why I am giving a solution to this particular case.
              – Zeekless
              Jul 18 at 12:37










            • Unsolvable ? No, it is always solvable, unless there are vertices on either sides of $12$.
              – Yves Daoust
              Jul 18 at 12:38







            • 1




              Mh, I am not convinced that the OP understood this in the general case. But we can't know. Anyway, it is easy to solve the problem without that constraint, or to check that the constraint is achievable.
              – Yves Daoust
              Jul 18 at 12:41







            • 1




              It is pretty ad-hoc, when a general solution is not much more complicated.
              – Yves Daoust
              Jul 18 at 12:44














            up vote
            -1
            down vote













            I will denote $v_ij=beginbmatrix x_j \ y_j endbmatrix - beginbmatrix x_i \ y_i endbmatrix$, that is the vector from $i$-point to $j$-point.



            $$
            beginbmatrix x_2 \ y_2 endbmatrix +fracv_12 cdot v_23Vertv_12Vert Big(fracv_12Vertv_12VertBig) = text coordinates of lower-right vertex.
            $$



            $$
            beginbmatrix x_1 \ y_1 endbmatrix +fracv_12 cdot v_15Vertv_12Vert Big(fracv_12Vertv_12VertBig)= text coordinates of lower-left vertex.
            $$



            $$
            beginbmatrix x_4 \ y_4 endbmatrix +fracv_12 cdot v_43Vertv_12VertBig(fracv_12Vertv_12VertBig) = text coordinates of upper-right vertex.
            $$



            $$
            beginbmatrix x_4 \ y_4 endbmatrix +fracv_12 cdot v_45Vertv_12Vert Big(fracv_12Vertv_12VertBig)= text coordinates of upper-left vertex.
            $$



            Fractions like $fracv_12 cdot v_45Vertv_12Vert$ are the projections of sides of the polygon onto the direction of the base, while $Big(fracv_12Vertv_12VertBig)$ is a unit vector of the base direction.






            share|cite|improve this answer























            • Now what if the polygon has six vertices ?
              – Yves Daoust
              Jul 18 at 12:37










            • @YvesDaoust, general answer is that the problem may be unsolvable (see my comment to the original question). That is why I am giving a solution to this particular case.
              – Zeekless
              Jul 18 at 12:37










            • Unsolvable ? No, it is always solvable, unless there are vertices on either sides of $12$.
              – Yves Daoust
              Jul 18 at 12:38







            • 1




              Mh, I am not convinced that the OP understood this in the general case. But we can't know. Anyway, it is easy to solve the problem without that constraint, or to check that the constraint is achievable.
              – Yves Daoust
              Jul 18 at 12:41







            • 1




              It is pretty ad-hoc, when a general solution is not much more complicated.
              – Yves Daoust
              Jul 18 at 12:44












            up vote
            -1
            down vote










            up vote
            -1
            down vote









            I will denote $v_ij=beginbmatrix x_j \ y_j endbmatrix - beginbmatrix x_i \ y_i endbmatrix$, that is the vector from $i$-point to $j$-point.



            $$
            beginbmatrix x_2 \ y_2 endbmatrix +fracv_12 cdot v_23Vertv_12Vert Big(fracv_12Vertv_12VertBig) = text coordinates of lower-right vertex.
            $$



            $$
            beginbmatrix x_1 \ y_1 endbmatrix +fracv_12 cdot v_15Vertv_12Vert Big(fracv_12Vertv_12VertBig)= text coordinates of lower-left vertex.
            $$



            $$
            beginbmatrix x_4 \ y_4 endbmatrix +fracv_12 cdot v_43Vertv_12VertBig(fracv_12Vertv_12VertBig) = text coordinates of upper-right vertex.
            $$



            $$
            beginbmatrix x_4 \ y_4 endbmatrix +fracv_12 cdot v_45Vertv_12Vert Big(fracv_12Vertv_12VertBig)= text coordinates of upper-left vertex.
            $$



            Fractions like $fracv_12 cdot v_45Vertv_12Vert$ are the projections of sides of the polygon onto the direction of the base, while $Big(fracv_12Vertv_12VertBig)$ is a unit vector of the base direction.






            share|cite|improve this answer















            I will denote $v_ij=beginbmatrix x_j \ y_j endbmatrix - beginbmatrix x_i \ y_i endbmatrix$, that is the vector from $i$-point to $j$-point.



            $$
            beginbmatrix x_2 \ y_2 endbmatrix +fracv_12 cdot v_23Vertv_12Vert Big(fracv_12Vertv_12VertBig) = text coordinates of lower-right vertex.
            $$



            $$
            beginbmatrix x_1 \ y_1 endbmatrix +fracv_12 cdot v_15Vertv_12Vert Big(fracv_12Vertv_12VertBig)= text coordinates of lower-left vertex.
            $$



            $$
            beginbmatrix x_4 \ y_4 endbmatrix +fracv_12 cdot v_43Vertv_12VertBig(fracv_12Vertv_12VertBig) = text coordinates of upper-right vertex.
            $$



            $$
            beginbmatrix x_4 \ y_4 endbmatrix +fracv_12 cdot v_45Vertv_12Vert Big(fracv_12Vertv_12VertBig)= text coordinates of upper-left vertex.
            $$



            Fractions like $fracv_12 cdot v_45Vertv_12Vert$ are the projections of sides of the polygon onto the direction of the base, while $Big(fracv_12Vertv_12VertBig)$ is a unit vector of the base direction.







            share|cite|improve this answer















            share|cite|improve this answer



            share|cite|improve this answer








            edited Jul 18 at 12:30


























            answered Jul 18 at 11:57









            Zeekless

            31110




            31110











            • Now what if the polygon has six vertices ?
              – Yves Daoust
              Jul 18 at 12:37










            • @YvesDaoust, general answer is that the problem may be unsolvable (see my comment to the original question). That is why I am giving a solution to this particular case.
              – Zeekless
              Jul 18 at 12:37










            • Unsolvable ? No, it is always solvable, unless there are vertices on either sides of $12$.
              – Yves Daoust
              Jul 18 at 12:38







            • 1




              Mh, I am not convinced that the OP understood this in the general case. But we can't know. Anyway, it is easy to solve the problem without that constraint, or to check that the constraint is achievable.
              – Yves Daoust
              Jul 18 at 12:41







            • 1




              It is pretty ad-hoc, when a general solution is not much more complicated.
              – Yves Daoust
              Jul 18 at 12:44
















            • Now what if the polygon has six vertices ?
              – Yves Daoust
              Jul 18 at 12:37










            • @YvesDaoust, general answer is that the problem may be unsolvable (see my comment to the original question). That is why I am giving a solution to this particular case.
              – Zeekless
              Jul 18 at 12:37










            • Unsolvable ? No, it is always solvable, unless there are vertices on either sides of $12$.
              – Yves Daoust
              Jul 18 at 12:38







            • 1




              Mh, I am not convinced that the OP understood this in the general case. But we can't know. Anyway, it is easy to solve the problem without that constraint, or to check that the constraint is achievable.
              – Yves Daoust
              Jul 18 at 12:41







            • 1




              It is pretty ad-hoc, when a general solution is not much more complicated.
              – Yves Daoust
              Jul 18 at 12:44















            Now what if the polygon has six vertices ?
            – Yves Daoust
            Jul 18 at 12:37




            Now what if the polygon has six vertices ?
            – Yves Daoust
            Jul 18 at 12:37












            @YvesDaoust, general answer is that the problem may be unsolvable (see my comment to the original question). That is why I am giving a solution to this particular case.
            – Zeekless
            Jul 18 at 12:37




            @YvesDaoust, general answer is that the problem may be unsolvable (see my comment to the original question). That is why I am giving a solution to this particular case.
            – Zeekless
            Jul 18 at 12:37












            Unsolvable ? No, it is always solvable, unless there are vertices on either sides of $12$.
            – Yves Daoust
            Jul 18 at 12:38





            Unsolvable ? No, it is always solvable, unless there are vertices on either sides of $12$.
            – Yves Daoust
            Jul 18 at 12:38





            1




            1




            Mh, I am not convinced that the OP understood this in the general case. But we can't know. Anyway, it is easy to solve the problem without that constraint, or to check that the constraint is achievable.
            – Yves Daoust
            Jul 18 at 12:41





            Mh, I am not convinced that the OP understood this in the general case. But we can't know. Anyway, it is easy to solve the problem without that constraint, or to check that the constraint is achievable.
            – Yves Daoust
            Jul 18 at 12:41





            1




            1




            It is pretty ad-hoc, when a general solution is not much more complicated.
            – Yves Daoust
            Jul 18 at 12:44




            It is pretty ad-hoc, when a general solution is not much more complicated.
            – Yves Daoust
            Jul 18 at 12:44












             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2855493%2fhow-to-get-a-rectangle-around-a-polygon%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?

            Relationship between determinant of matrix and determinant of adjoint?

            Color the edges and diagonals of a regular polygon