2

Consider the following (almost) MWE:

% lualatex test.tex
\documentclass{article}

\usepackage{pstricks-add}

\begin{document}

\begin{figure}
 \psset{unit = 0.4}
  \begin{pspicture}(-12,\fpeval{-6*sqrt(3)})(12,\fpeval{6*sqrt(3)})
    \pnodes
      (0,0){O}
      (-6,\fpeval{-6*sqrt(3)}){A}
      (-3,\fpeval{-3*sqrt(3)}){B}
      ( 3,\fpeval{-3*sqrt(3)}){C}
      ( 6,\fpeval{-6*sqrt(3)}){D}
    \pspolygon(A)(B)(C)(D)
    \psrotate(O){60}{\pspolygon(A)(B)(C)(D)}
  \end{pspicture}
\end{figure}

\end{document}

When I compile using lualatex the new, rotated trapezoid isn't drawn.

How do I draw the rotation object and what is wrong with the code above?

Update

Here is what I ended up with:

% lualatex test.tex
\documentclass{article}

\usepackage{pstricks-add}

\begin{document}

\begin{figure}
\def\Ax{6 }
\def\Ay{0 }
\def\Bx{3 }
\def\By{\fpeval{3*sqrt(3)} }
\def\Cx{\fpeval{2*\Bx} }
\def\Cy{\fpeval{2*\By} }
\def\Dx{\fpeval{2*\Ax} }
\def\Dy{\fpeval{2*\Ay} }
 \centering
 \psset{unit = 0.64}
  \begin{pspicture}(-12,\fpeval{-6*sqrt(3)})(12,\fpeval{6*sqrt(3)})
    \pnodes
      (!\Bx \By){I1}
      (!\Bx \By neg){I5}
      (!\Ax \Ay){I6}
      (!2 \Bx mul 2 \By mul){Y1}
      (!2 \Bx mul 2 \By mul neg){Y5}
      (!2 \Ax mul 2 \Ay mul){Y6}
    \multido
      {\i = 0+60}
      {6}
      {\psrotate(0,0){\i}{
         \pspolygon[
           linejoin = 1,
           fillstyle = solid,
           fillcolor = blue!40!white
         ](\Ax,\Ay)(\Bx,\By)(\Cx,\Cy)(\Dx,\Dy)
%         \psdots(\Bx,\By)(\Cx,\Cy)
       }}
    \pstMarkAngle{I5}{I6}{Y6}{\ang{120}}
    \pstMarkAngle{Y6}{I6}{I1}{\ang{120}}
    \pstMarkAngle{I6}{Y6}{Y5}{\ang{60}}
    \pstMarkAngle{Y1}{Y6}{I6}{\ang{60}}
  \end{pspicture}
\end{figure}

\end{document}

P.S. The PostScript notation was just for myself, to see if I could remember how to use it.

5
  • 2
    The nodes aren't rotated. You should follow a similar trick you did here: Rotate PSTricks Object: Label Positioning; define variables for the positions and use those, as they will be rotated.
    – Werner
    Commented Jul 11 at 0:10
  • @Werner I've tried that in the updated question but to no good. :-( Commented Jul 11 at 0:48
  • 1
    I know precisely zilch about pstricks, so @Werner please correct me, but you're using fixed points rather than coordinates in the rotation. It seems to me for the coordinates to be rotated, you must specify them as coordinates and not as already-fixed points.
    – cfr
    Commented Jul 11 at 5:00
  • 1
    @SvendTveskæg: You did it a bit differently to what I linked to (you should use the coordinates in the \psrotated \pspolygon, not the nodes. Setting a node makes it immutable (= fixed). So, the rotation can't apply to the named point. I'm sure there is some internal update to pstricks that could allow for this, but not currently.
    – Werner
    Commented Jul 11 at 15:42
  • @Werner Thanks for the explanation! Commented Jul 11 at 20:36

2 Answers 2

2

Like this?

polygon and rotated polygon

Note that all I did was follow Werner's link, copy Bernard's code, minimise your example and compare. I couldn't draw anything in pstricks if my life depended on it. Caveat emptor.

\documentclass[border=5pt]{standalone}
% addaswyd o ateb Bernard: https://tex.stackexchange.com/a/313389/
\usepackage{pstricks-add}

\begin{document}
{\def\IAx{\fpeval{ 6*cosd( 60)}}%
\def\IAy{\fpeval{ 6*sind( 60)}}%
\def\IFx{\fpeval{ 6*cosd(360)}}%
\def\IFy{\fpeval{ 6*sind(360)}}%
\def\YAx{\fpeval{12*cosd( 60)}}%
\def\YAy{\fpeval{12*sind( 60)}}%
\def\YFx{\fpeval{12*cosd(360)}}%
\def\YFy{\fpeval{12*sind(360)}}%
\psset{unit = 0.4}%
\begin{pspicture}(-12,\fpeval{-6*sqrt(3)})(12,\fpeval{6*sqrt(3)})
  \pnodes
    (0,0){O}
    (\IAx,\IAy){IA}
    (\IFx,\IFy){IF}
    (\YAx,\YAy){YA}
    (\YFx,\YFy){YF}
  \pspolygon[linecolor=red](YF)(IF)(IA)(YA)
  \psrotate(O){60}{\pspolygon[linecolor=blue](\YFx,\YFy)(\IFx,\IFy)(\IAx,\IAy)(\YAx,\YAy)}
\end{pspicture}}


\end{document}
3
  • I don't understand why I can't use the \pnodes at points when rotating an object, but your code works just fine, so thanks alot! :-) Commented Jul 11 at 7:39
  • 1
    @SvendTveskæg If you'd rather I remove this and see if somebody who can answer that explains, just let me know (and unaccept or I can't delete). I was guessing it was similar to pgf/tikz, which is why I tried this. In pgf, a coordinate transformation never changes named points, but only points specified by coordinates. That's often handy, but not in a case like this. I know that pgf/tikz often works similarly to pstricks, so I figured this might be such a case. But I haven't done anything radical such as read the docs or anything :-).
    – cfr
    Commented Jul 11 at 14:25
  • You don't have to delete your answer. Since your modifications made the code work as I hoped for, I'll keep your answer as the accepted one. :-) Commented Jul 11 at 20:34
2

That does not work with an object defined by nodes.

% lualatex test.tex
\documentclass{article}
\usepackage{pstricks-add}
\def\myPolygon#1{\pspolygon[linecolor=#1]
    (-6,\fpeval{-6*sqrt(3)})
    (-3,\fpeval{-3*sqrt(3)})
    ( 3,\fpeval{-3*sqrt(3)})
    ( 6,\fpeval{-6*sqrt(3)})}

\begin{document}
    
 \psset{unit = 0.4}
\begin{pspicture}[showgrid](-12,\fpeval{-6*sqrt(3)})(12,\fpeval{6*sqrt(3)})
  \myPolygon{black}
  \psrotate(0,0){60}{\myPolygon{red}}
  \psrotate(0,0){120}{\myPolygon{green}}
  \psrotate(0,0){180}{\myPolygon{blue}}
  \psdot(O)
\end{pspicture}
    
\end{document}

enter image description here

if you still need nodes for the coordinates, use:

    \begin{pspicture}(-12,\fpeval{-6*sqrt(3)})(12,\fpeval{6*sqrt(3)})
        \pnodes{A}
        (0,0)
        (-6,\fpeval{-6*sqrt(3)})
        (-3,\fpeval{-3*sqrt(3)})
        ( 3,\fpeval{-3*sqrt(3)})
        ( 6,\fpeval{-6*sqrt(3)})
        \pspolygon(A1)(A2)(A3)(A4)
        \multido{\iA=1+1}{4}{\psRelLine[angle=60,linestyle=none](A0)(A\iA){1}{a\iA}}
        \pspolygon[linecolor=red](a1)(a2)(a3)(a4)
        \multido{\iA=1+1}{4}{\psRelLine[angle=120,linestyle=none](A0)(A\iA){1}{a\iA}}
        \pspolygon[linecolor=green](a1)(a2)(a3)(a4)
        \multido{\iA=1+1}{4}{\psRelLine[angle=180,linestyle=none](A0)(A\iA){1}{a\iA}}
        \pspolygon[linecolor=blue](a1)(a2)(a3)(a4)
    \end{pspicture}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .