# [pstricks] conceptual question for pst-optexp

Christoph Bersch usenet at bersch.net
Wed May 28 13:30:15 CEST 2008

Hi,

I have a question regarding the design of new components for pst-optexp.
Currently there are transmittive objects (e.g. lenses)

\lens(A)(B){L}

and reflective objects (e.g. mirrors).

\mirror(A)(G)(B){M}

In both cases all used nodes have to be defined by the user.

Now I am planning to provide new objects with multiple internal
reflections. That means that I have to define new nodes inside the
object and make them accessible for the user in order to draw the beam.

To illustrate the problem a bit, consider the following example:

\documentclass{article}
\usepackage{pst-node}
\SpecialCoor
\makeatletter
\def\pentaprism{%
\edef\@pp at size{2\space}%
\pscustom{%
\psline(! \@pp at size 2 sqrt div 0)%
(! \@pp at size 2 sqrt div 67.5 cos \@pp at size
mul 67.5 sin div sub \@pp at size)%
(! 67.5 cos \@pp at size mul 67.5 sin div
\@pp at size 2 sqrt div sub \@pp at size)%
(! \@pp at size 2 sqrt div neg 0)%
(! 0 \@pp at size 2 sqrt div neg)%
\closepath
}%
\pnode(! \@pp at size 2 sqrt div 67.5 cos \@pp at size mul
67.5 sin 2 mul div sub \@pp at size 2 div){PentaPrism1}%
\pnode(! 67.5 cos \@pp at size mul 67.5 sin 2 mul div
\@pp at size 2 sqrt div sub \@pp at size 2 div){PentaPrism2}%
}%
\makeatother

\begin{document}
\begin{pspicture}[showgrid=true](5,5)
\rput[lb]{-45}(3,3){\pentaprism}
\pnode(0,0){origin}
\psline[linecolor=green](origin|PentaPrism1)%
(PentaPrism1)%
(PentaPrism2)%
(PentaPrism2|origin)
\end{pspicture}
\end{document}

Here, the nodes 'PentaPrism1' and 'PentaPrism2' must be created within
the object definition but the user must be able to access them.

I was thinking about defining a new key 'compname' which takes a name
for the component and which is used as prefix for the internal nodes:

\pentaprism[compname=PP](A)(G)(B){prism}

would then create two nodes e.g. 'PPInput' and 'PPOutput' which can be
accessed by the user lateron.

Do you think this is a good way to implement it or are there better ways?

Thank you for reading this long message :-)