Graphics, Figures & Tablespst-poly | Center of a Polygon (again)

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

pst-poly | Center of a Polygon (again)

Post by svend_tveskaeg »

Hi all.

First: On http://latex-community.org/forum/viewtopic.php?t=21601, Thorsten pointed me to an example on how to define the center of a \psPolygon. I am not sure if the following has anything to do with this.

Consider the following MWE:

Code: Select all

\documentclass{article}

\usepackage{auto-pst-pdf,pst-poly,pstricks-add}
\usepackage{expl3}

\ExplSyntaxOn
  \cs_new_eq:NN
    \calculate
  \fp_eval:n
\ExplSyntaxOff

\begin{document}

\begin{figure}
\def\AntalSider{8 }
\def\Sidelaengde{60 }
\def\RadiusB{78.39377789258259 }
%\def\RadiusB{\calculate{\Sidelaengde/(2*sin(180/\AntalSider))} }
\def\RelVinkel{\calculate{360/\AntalSider} }
\def\Rotation{\calculate{\RelVinkel/2} }
 \centering
  \begin{pspicture}[showgrid=false](156.8,156.8)
  \psset{unit=0.05cm}
   \pnode(!\RadiusB \RadiusB){A}
   \pscircle(A){\RadiusB}
   \PstPolygon[PolyNbSides=\AntalSider,PolyRotation=\Rotation,unit=\RadiusB]
  \end{pspicture}
\end{figure}

\end{document}
This compiles just fine but when

Code: Select all

\def\RadiusB{78.39377789258259 }
is commented out instead of

Code: Select all

\def\RadiusB{\calculate{\Sidelaengde/(2*sin(180/\AntalSider))} }
it will not compile. I simply do not understand this since

Code: Select all

60/(2*sin(180/8)) = 78.39377789258259
I would really like to have the latter of the two definitions of \RadiusB so that I do not have to re-calculate the radius of the circle (\RadiusB) manually every time I change the number of vertices of the polygon (\AntalSider) or the length of the sides in the polygon (\Sidelaengde).

Thank you in advance!
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

Post Reply