Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider the following example.

Code

% pdflatex -shell-escape test.tex

\documentclass{article}

\usepackage{
  auto-pst-pdf,
  pst-eucl,
  pstricks-add
}
\usepackage[
  locale=DE
]{siunitx}

\begin{document}

\begin{figure}
\def\radius{21.65 }      % radius
\def\vinkelA{12 }        % angle
\def\faktor{0.33333333 } % scaling
\newlength\maksimum      % define length
\maksimum=\radius\psunit % set the length to the current value/unit
\maksimum=2\dimexpr\faktor\maksimum
 \centering
 \psset{
   unit=0.8cm,
   linecolor=red
 }
  \begin{pspicture}(\maksimum,\maksimum)
   \pnode(!2 \faktor \radius mul mul \faktor \radius mul){A}
   \pnode(!\faktor \radius mul \faktor \radius mul){B}
   \pnode(!\faktor \radius mul 1 \vinkelA cos add \faktor \radius mul mul){C}
   \psline(A)(!2 \faktor \radius mul mul 0)(0,0)(!0 \faktor \radius mul)
   \psarc(B){!\faktor \radius mul}{0}{!90 \vinkelA sub}
   \psarc(B){!\faktor \radius mul}{!90 \vinkelA add}{180}
   \psline[linestyle=dashed](!0 \faktor \radius mul)(A)
   \psarc[linestyle=dashed](B){!\faktor \radius mul}{180}{360}
  \psset{
    linecolor=blue,
    linewidth=1.5pt
  }
   \psRelLine[angle=!270 \vinkelA add](B)(!0 \faktor \radius mul){1}{P1}
   \psRelLine[angle=!90 \vinkelA sub](B)(A){1}{P2}
   \pcline(B)(P1)
   \pcline(B)(P2)
   \pcline[linestyle=none](P1)(P2)
   \aput*{:U}{Oculus}
   \pcline(P1)(P2)
   \pcline(B)(C)
  \psset{
    linecolor=black,
    linewidth=0.5pt,
    MarkAngleRadius=3.7,
    LabelSep=4
  }
   \psRelLine[linestyle=dotted,angle=45]{<->}(B)(A){1}{V}
   \ncline[linestyle=none]{B}{V}
   \naput[nrot=:U]{\small\SI{\radius}{\m}}
   \pstMarkAngle{C}{B}{P1}{\scriptsize\SI{\vinkelA}{\degree}}
   \pstMarkAngle{P2}{B}{C}{\scriptsize\SI{\vinkelA}{\degree}}
   \pstRightAngle{P1}{C}{B}
   \pstRightAngle{P2}{C}{B}
  \end{pspicture}
\end{figure}

\end{document}

Output

Output.

Question

I would like to improve the code. I have already improved it somewhat from where I started, but I can quite clearly get even better.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted
\documentclass{article}
\usepackage{auto-pst-pdf,pst-node}

\begin{document}
\psset{unit=3mm}
\def\radius{21.65 }      % radius
\def\vinkelA{12 }        % angle

\begin{pspicture}(-\radius,-\radius)(\radius,\radius)
  \psarc[linestyle=dashed,linecolor=red](0,0){\radius}{180}{360}
  \psarc[linecolor=red](0,0){\radius}{0}{!90 \vinkelA sub}
  \psarc[linecolor=red](0,0){\radius}{!90 \vinkelA add}{180}
  \psline[linecolor=red](-\radius,0)(-\radius,-\radius)(\radius,-\radius)(\radius,0)
  \psline[linecolor=red,linestyle=dashed](-\radius,0)(\radius,0)
  \psarc(0,0){!\radius 2 div}{!90 \vinkelA sub}{!90 \vinkelA add}
  \uput[90](!\radius 2 div 90 \vinkelA 2 div sub PtoC){$\vinkelA^\circ$}
  \uput[90](!\radius 2 div 90 \vinkelA 2 div add PtoC){$\vinkelA^\circ$}
  \pnode(!0 \radius \vinkelA cos mul){Oculus}
  \pspolygon[linecolor=blue,linewidth=1.5pt,linejoin=1]%
    (!\radius 90 \vinkelA add PtoC)(0,0)(!\radius 90 \vinkelA sub PtoC)
  \psline[linecolor=blue,linewidth=1.5pt](Oculus)
  \psline[linestyle=dotted]{<->}(\radius;45)
  \uput[90]{45}(!\radius 2 div 45 PtoC){\radius}
  \uput[90](0,\radius){Oculus}
  \rput[t](Oculus){\psline(-1.5,0)(-1.5,-1.5)(1.5,-1.5)(1.5,0)}
\end{pspicture}

\end{document}

enter image description here

share|improve this answer
    
Really nice, Herbert! –  Svend Tveskæg Apr 29 '13 at 22:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.