How to get a rectangle around a polygon?
Clash 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?
(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)
geometry trigonometry vectors
 |Â
show 9 more comments
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?
(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)
geometry trigonometry vectors
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
 |Â
show 9 more comments
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?
(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)
geometry trigonometry vectors
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?
(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)
geometry trigonometry vectors
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
 |Â
show 9 more comments
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
 |Â
show 9 more comments
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).
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
add a comment |Â
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$.
add a comment |Â
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.
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
 |Â
show 9 more comments
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).
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
add a comment |Â
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).
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
add a comment |Â
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).
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).
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
add a comment |Â
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
add a comment |Â
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$.
add a comment |Â
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$.
add a comment |Â
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$.
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$.
answered Jul 18 at 12:12
A. Pongrácz
2,574321
2,574321
add a comment |Â
add a comment |Â
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.
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
 |Â
show 9 more comments
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.
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
 |Â
show 9 more comments
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.
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.
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
 |Â
show 9 more comments
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
 |Â
show 9 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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