General ⇒ PSTricks: How to draw a polygon if all angles are given ?
PSTricks: How to draw a polygon if all angles are given ?
Assume I have a polygon with all angles are given.
First I align one side of the polygon with the x axis. Assign this side a length as a measuring standard. Using sine's rule, obtain the coordinate of each vertices. The polygon is then drawn by invoking \pspolygon in post script notation.
However, this method is time-consuming and error prone.
Is there any package to do that easily?
Thank you.
First I align one side of the polygon with the x axis. Assign this side a length as a measuring standard. Using sine's rule, obtain the coordinate of each vertices. The polygon is then drawn by invoking \pspolygon in post script notation.
However, this method is time-consuming and error prone.
Is there any package to do that easily?
Thank you.
Last edited by yoyoimut on Tue Sep 07, 2010 3:57 am, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
PSTricks: How to draw a polygon if all angles are given ?
You didn't write if these angles are all equal or not. If they are, just use the [url=http://ctan,org/pkg/pst-poly]pst-poly[/url] package.yoyoimut wrote:Assume I have a polygon with all angles are given. […] Is there any package to do that easily?
Best regards
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
PSTricks: How to draw a polygon if all angles are given ?
yoyoimut wrote:Assume I have a polygon with all angles are given. […] Is there any package to do that easily?
Not necessarily equal.localghost wrote: You didn't write if these angles are all equal or not. If they are, just use the [url=http://ctan,org/pkg/pst-poly]pst-poly[/url] package.
-
- Posts: 351
- Joined: Sat Aug 02, 2008 8:47 am
PSTricks: How to draw a polygon if all angles are given ?
yoyoimut wrote:Assume I have a polygon with all angles are given.
First I align one side of the polygon with the x axis. Assign this side a length as a measuring standard. Using sine's rule, obtain the coordinate of each vertices. The polygon is then drawn by invoking \pspolygon in post script notation.
However, this method is time-consuming and error prone.
Is there any package to do that easily?
Code: Select all
\documentclass{article}
\usepackage{pstricks}
\SpecialCoor
\begin{document}
\begin{pspicture}[showgrid](10,10)
\rput(5,5){%
\pspolygon[linecolor=blue](5;0)(5;15)(5;45)(5;70)(5;190)(5;230)
\pspolygon(5;0)(5;15)(5;45)(4;70)(5;190)(3;230)}
\end{pspicture}
\end{document}
PSTricks: How to draw a polygon if all angles are given ?
yoyoimut wrote:Assume I have a polygon with all angles are given.
First I align one side of the polygon with the x axis. Assign this side a length as a measuring standard. Using sine's rule, obtain the coordinate of each vertices. The polygon is then drawn by invoking \pspolygon in post script notation.
However, this method is time-consuming and error prone.
Is there any package to do that easily?
Assume I have 5 angles where the sum of them is equal to 540 degrees.CrazyHorse wrote:Code: Select all
\documentclass{article} \usepackage{pstricks} \SpecialCoor \begin{document} \begin{pspicture}[showgrid](10,10) \rput(5,5){% \pspolygon[linecolor=blue](5;0)(5;15)(5;45)(5;70)(5;190)(5;230) \pspolygon(5;0)(5;15)(5;45)(4;70)(5;190)(3;230)} \end{pspicture} \end{document}
There is no information about the length.
If I assign a fixed length (as a reference length) to one side and find the other sides based on this reference, I will be able to do what you explained above (using polar coordinate). This approach forces me to use post script notation that is complicated and error prone.
I don't know whether or not there is a package that can do it easily.
Thank you.
-
- Posts: 351
- Joined: Sat Aug 02, 2008 8:47 am
PSTricks: How to draw a polygon if all angles are given ?
give a _complete_ running example which shows what you already did.yoyoimut wrote: Assume I have 5 angles where the sum of them is equal to 540 degrees.
There is no information about the length.
If I assign a fixed length (as a reference length) to one side and find the other sides based on this reference, I will be able to do what you explained above (using polar coordinate). This approach forces me to use post script notation that is complicated and error prone.
I don't know whether or not there is a package that can do it easily.
Herbert
PSTricks: How to draw a polygon if all angles are given ?
yoyoimut wrote: Assume I have 5 angles where the sum of them is equal to 540 degrees.
There is no information about the length.
If I assign a fixed length (as a reference length) to one side and find the other sides based on this reference, I will be able to do what you explained above (using polar coordinate). This approach forces me to use post script notation that is complicated and error prone.
I don't know whether or not there is a package that can do it easily.
OK. Please see the code below:CrazyHorse wrote: give a _complete_ running example which shows what you already did.
Herbert
Code: Select all
\documentclass{article}
\usepackage{pst-node}
\begin{document}
\psset{unit=6cm,gridcolor=green,subgridcolor=lightgray,gridlabels=5pt,gridlabelcolor=red}
\begin{pspicture}(-0.1,-0.1)(2,2.1)
\psgrid
\SpecialCoor
\pstVerb{/side 1 def}
\pnode(!0 side){A}\uput[180](A){$A$}
\pnode(!0 0){B}\uput[225](B){$B$}
\pnode(!80 sin 2 exp side mul 40 sin div 70 sin div 0){C}\uput[-45](C){$C$}
\pnode(!80 sin side mul 30 sin div 20 cos mul 80 sin side mul 30 sin div 20 sin mul){D}\uput[0](D){$D$}
\pnode(!50 sin side mul 20 sin div 60 cos mul 50 sin side mul 20 sin div 60 sin mul){E}\uput[90](E){$E$}
\pnode(!80 sin side mul 70 sin div 60 cos mul 80 sin side mul 70 sin div 60 sin mul){P}\uput[110](P){$P$}
\pnode(!80 sin 2 exp side mul 60 sin div 70 sin div 20 cos mul 80 sin 2 exp side mul 60 sin div 70 sin div 20 sin mul){Q}\uput[80](Q){$Q$}
\pspolygon(A)(B)(C)(D)(E)
\psset{linecolor=red}
\psline(A)(D)
\psline(B)(E)
\psset{linecolor=blue}
\psline(P)(C)
\psline(B)(D)
\psset{linecolor=magenta,linewidth=0.8pt,arcsep=\pslinewidth,arrows=<->}
\psarc[origin={A}](A){30pt}{(D)}{(E)}\uput{15pt}[15](A){$\theta$}
\psarc[origin={B}](B){45pt}{(E)}{(A)}\uput{25pt}[75](B){$30^\circ$}
\psarc[origin={B}](B){45pt}{(C)}{(D)}\uput{25pt}[10](B){$20^\circ$}
\psarc[origin={B}](B){45pt}{(D)}{(E)}\uput{25pt}[40](B){$\alpha$}
\psarc[origin={D}](D){40pt}{(A)}{(B)}\uput{15pt}[187.5](D){$30^\circ$}
\psarc[origin={D}](D){40pt}{(B)}{(C)}\uput{15pt}[235](D){$50^\circ$}
\psarc[origin={D}](D){40pt}{(E)}{(A)}\uput{15pt}[140](D){$50^\circ$}
\psarc[origin={C}](C){35pt}{(D)}{(P)}\uput{15pt}[100](C){$70^\circ$}
\psarc[origin={C}](C){35pt}{(P)}{(B)}\uput{13pt}[160](C){$40^\circ$}
\psarc[origin={P}](P){45pt}{(C)}{(D)}\uput{20pt}[-25](P){$30^\circ$}
\end{pspicture}
\end{document}
Yoyoimut
-
- Posts: 351
- Joined: Sat Aug 02, 2008 8:47 am
PSTricks: How to draw a polygon if all angles are given ?
do you need something like this?yoyoimut wrote:Code: Select all
\documentclass{article} \usepackage{pst-node} \begin{document} \psset{unit=6cm,gridcolor=green,subgridcolor=lightgray,gridlabels=5pt,gridlabelcolor=red} \begin{pspicture}(-0.1,-0.1)(2,2.1) \psgrid \SpecialCoor \pstVerb{/side 1 def} \pnode(!0 side){A}\uput[180](A){$A$} \pnode(!0 0){B}\uput[225](B){$B$} \pnode(!80 sin 2 exp side mul 40 sin div 70 sin div 0){C}\uput[-45](C){$C$} \pnode(!80 sin side mul 30 sin div 20 cos mul 80 sin side mul 30 sin div 20 sin mul){D}\uput[0](D){$D$} \pnode(!50 sin side mul 20 sin div 60 cos mul 50 sin side mul 20 sin div 60 sin mul){E}\uput[90](E){$E$} \pnode(!80 sin side mul 70 sin div 60 cos mul 80 sin side mul 70 sin div 60 sin mul){P}\uput[110](P){$P$} \pnode(!80 sin 2 exp side mul 60 sin div 70 sin div 20 cos mul 80 sin 2 exp side mul 60 sin div 70 sin div 20 sin mul){Q}\uput[80](Q){$Q$} \pspolygon(A)(B)(C)(D)(E) \end{pspicture} \end{document}
Code: Select all
\pscustom[linewidth=2pt]{
\moveto(0,1)
\rlineto(0,-1)
\rotate{-90}
\rlineto(0,1.6)
\rotate{-110}
\rlineto(0,-0.71)
\rotate{-130}
\rlineto(0,1.45)
\closepath
}
PSTricks: How to draw a polygon if all angles are given ?
yoyoimut wrote:Code: Select all
\documentclass{article} \usepackage{pst-node} \begin{document} \psset{unit=6cm,gridcolor=green,subgridcolor=lightgray,gridlabels=5pt,gridlabelcolor=red} \begin{pspicture}(-0.1,-0.1)(2,2.1) \psgrid \SpecialCoor \pstVerb{/side 1 def} \pnode(!0 side){A}\uput[180](A){$A$} \pnode(!0 0){B}\uput[225](B){$B$} \pnode(!80 sin 2 exp side mul 40 sin div 70 sin div 0){C}\uput[-45](C){$C$} \pnode(!80 sin side mul 30 sin div 20 cos mul 80 sin side mul 30 sin div 20 sin mul){D}\uput[0](D){$D$} \pnode(!50 sin side mul 20 sin div 60 cos mul 50 sin side mul 20 sin div 60 sin mul){E}\uput[90](E){$E$} \pnode(!80 sin side mul 70 sin div 60 cos mul 80 sin side mul 70 sin div 60 sin mul){P}\uput[110](P){$P$} \pnode(!80 sin 2 exp side mul 60 sin div 70 sin div 20 cos mul 80 sin 2 exp side mul 60 sin div 70 sin div 20 sin mul){Q}\uput[80](Q){$Q$} \pspolygon(A)(B)(C)(D)(E) \end{pspicture} \end{document}
CrazyHorse wrote: do you need something like this?HerbertCode: Select all
\pscustom[linewidth=2pt]{ \moveto(0,1) \rlineto(0,-1) \rotate{-90} \rlineto(0,1.6) \rotate{-110} \rlineto(0,-0.71) \rotate{-130} \rlineto(0,1.45) \closepath }
I really need something that can help me not to calculate the sides (if possible).
Just by giving the five angles and a scaling factor to the pstricks, I get the polygon.
Thank you.
regards,
Yoyoimut
-
- Posts: 351
- Joined: Sat Aug 02, 2008 8:47 am
PSTricks: How to draw a polygon if all angles are given ?
you need at least three sides to get one polynom,yoyoimut wrote: I really need something that can help me not to calculate the sides (if possible).
Just by giving the five angles and a scaling factor to the pstricks, I get the polygon.
otherwise there exists more than one solution.
Herbert