4

Consider the following code:

\documentclass{article}

\usepackage{pst-eucl}
\usepackage{siunitx}

% LaTeX 3 syntax
\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff

% constants
\def\northB{\calc{90-\north} }
\def\lengthC{\calc{\length*sin(\northB*pi/180)} }
\def\lengthB{\calc{\length*sin(\north* pi/180)} }
\def\coorx{\calc{\lengthC*sin(\northB*pi/180)} }
\def\coory{\calc{\lengthB*cos(\north* pi/180)} }
\def\maxx{\calc{\length+0.45} }
\def\maxyA{\calc{1/2*\lengthB*(sin(\north*pi/180)+cos(\north*pi/180))} }
\def\maxyB{\calc{\coory+0.6} }

\begin{document}

% settings
\psset{unit = 0.67}
\sisetup{round-mode = places, round-precision = 1}
% constants
\def\length{16 }
\def\north{55 }
% picture
\begin{pspicture}(-0.6,-0.15)(\maxx,\maxyB)
  \pnodes{P}(0,0)(\coorx,\coory)(\length,0)
  \pspolygon(P0)(P1)(P2)
  \pstMarkAngle{P2}{P0}{P1}{\SI{\north}{\degree}}
  \pstRightAngle{P0}{P1}{P2}
  \pstMarkAngle{P1}{P2}{P0}{\SI{\northB}{\degree}}
  \uput[180](P0){$A$}
  \uput[90](P1){$C$}
  \uput[0](P2){$B$}
  \pstMediatorAB[
    PointSymbol = none,
    PointNameA = none,
    PointNameB = none,
    CodeFig = true,
    CodeFigColor = black
  ]{P1}{P2}{M}{MN}
  \psset{offset = -9pt, linestyle = none, nrot = :U}
  \pcline(P0)(P1)
  \ncput*{\SI{\lengthC}{\cm}}
  \pcline(P1)(P2)
  \ncput*{\SI{\lengthB}{\cm}}
  \pcline[offset = 9pt](P0)(P2)
  \ncput*{\SI{\length}{\cm}}
\end{pspicture}

\end{document}

output

How do I make PSTricks choose \maxyA if this value is bigger than \maxyB and choose \maxyB if this value is bigger than \maxyA, I.e., choose the biggest of the two values? (I'm talking about the hight of the PSTricks frame.)

Update

Here is what I ended up with:

\documentclass{article}

\usepackage{pst-eucl}
\usepackage{siunitx}

% LaTeX 3 syntax
\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff

% constants
\def\northB{\calc{90-\north}}
\def\lengthB{\calc{\length*sin(\northB*pi/180)}}
\def\lengthC{\calc{\length*sin(\north* pi/180)}}
\def\coorx{\calc{\lengthB*sin(\northB*pi/180)}}
\def\coory{\calc{\lengthC*cos(\north* pi/180)}}
\def\maxxA{\calc{\length+0.45}}
\def\maxxB{\calc{1/4*\length*(sin(2*\north*pi/180)+cos(2*\north*pi/180)+3)}}
\def\maxx{\calc{max(\maxxA,\maxxB)}}
\def\maxyA{\calc{1/2*\lengthC*(sin(\north*pi/180)+cos(\north*pi/180))}}
\def\maxyB{\calc{\coory+0.6}}
\def\maxy{\calc{max(\maxyA,\maxyB)}}

\begin{document}

% settings
\psset{unit = 0.67}
\sisetup{round-mode = places, round-precision = 1}
% constants
\def\length{16 }
\def\north{55 }
% picture
\begin{pspicture}(-0.6,-0.15)(\maxx,\maxy)
  \pnodes{P}(0,0)(\coorx,\coory)(\length,0)
  \pspolygon(P0)(P1)(P2)
  \pstMarkAngle{P2}{P0}{P1}{\SI{\north}{\degree}}
  \pstRightAngle{P0}{P1}{P2}
  \pstMarkAngle{P1}{P2}{P0}{\SI{\northB}{\degree}}
  \uput[180](P0){$A$}
  \uput[90](P1){$C$}
  \uput[0](P2){$B$}
  \pstMediatorAB[
    PointSymbol = none,
    PointNameA = none,
    PointNameB = none,
    CodeFig = true,
    CodeFigColor = black
  ]{P1}{P2}{M}{MN}
  \psset{offset = -9pt, linestyle = none, nrot = :U}
  \pcline(P0)(P1)
  \ncput*{\SI{\lengthB}{\cm}}
  \pcline(P1)(P2)
  \ncput*{\SI{\lengthC}{\cm}}
  \pcline[offset = 9pt](P0)(P2)
  \ncput*{\SI{\length}{\cm}}
\end{pspicture}

\end{document}
0

1 Answer 1

3
+150

Use the definition

\def\maxy{\calc{max(\maxyA, \maxyB)} }

to get the maximum value.

\begin{pspicture}[showgrid](-0.6,-0.15)(\maxx,\maxy)
...
2
  • Great! This is rather simpel. :) Sep 18, 2013 at 9:04
  • @SvendTveskæg That was my first and only guess, haven't worked with this, yet. But this way to do calulations is great, thanks for asking the question :).
    – Christoph
    Sep 18, 2013 at 9:07

You must log in to answer this question.

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