Featured Book

LaTeX Beginners Guide

Who is online

In total there are 5 users online :: 1 registered, 0 hidden and 4 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: Bing [Bot] and 4 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

PSTricks | Cut off part of parallelogram if ... Topic is solved

Add tags Information and discussion about graphics, figures & tables in LaTeX documents.

PSTricks | Cut off part of parallelogram if ...  Topic is solved

Postby svend_tveskaeg on Wed Oct 10th, 2012

First: The topic probably needs a better headline. This was the best I could come up with.

Hi all.

Consider the following MWE, illustrating rays of light coming from the Sun through the Oculus in the Pantheon, Rome:

Code: Select all  •  Open in writeLaTeX
\documentclass{article}

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

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

\begin{document}

\def\radius{21.65
} % Radius of the dome
\def\vinkelA{12 }   % Width of the Oculus
\def\vinkelB{71 }   % Angle of the Sun's rays
\def\faktor{\calculate{1/3} }
\def\RelRadius{\calculate{\faktor*\radius} }
\def\vinkelC{\calculate{90-\vinkelA} }
\def\vinkelD{\calculate{90+\vinkelA} }
\def\vinkelE{\calculate{180+\vinkelC} }
\def\vinkelF{\calculate{180+\vinkelD} }
\def\vinkelG{\calculate{180-\vinkelB} }
\def\vinkelH{\calculate{180+\vinkelG} }
\begin{figure}
 \centering
  \begin{pspicture}(44,50)
  \psset{unit=0.5cm,linecolor=red}
   \pnode(0,0){A}
   \pnode(!0 \RelRadius){B}
   \pnode(!2 \RelRadius mul \RelRadius){C}
   \pnode(!2 \RelRadius mul 0){D}
   \pnode(!\RelRadius \RelRadius){E}
   \psarc(E){\RelRadius}{0}{\vinkelC}
   \psarc(E){\RelRadius}{\vinkelD}{180}
  \psset{linestyle=none,linecolor=black,dotsep=2pt}
   \psRelLine[angle=\vinkelF](E)(B){1}{P1}
   \psRelLine[angle=\vinkelE](E)(B){1}{P2}
   \psRelLine[angle=\vinkelG](P1)(P2){1}{L1}
   \psRelLine[angle=\vinkelH,linestyle=dotted](P2)(P1){1}{L2}
   \psRelLine[angle=\vinkelG](P2)(P1){1 \vinkelA cos add 2 \vinkelA sin mul \vinkelB sin mul div}{L3}
   \psParallelLine(L2)(L3)(L1){1}{L4}
   \pspolygon[fillstyle=solid,fillcolor=yellow](L1)(L2)(L3)(L4)
   \pnode(!0 1 \vinkelA cos add \RelRadius mul){T1}
   \pnode(!2 \RelRadius mul 1 \vinkelA cos add \RelRadius mul){T2}
   \pcline[linestyle=dotted](T1)(T2)
   \pstMarkAngle[linestyle=solid,MarkAngleRadius=0.8,LabelSep=1.5,arrows=<->]{L2}{P2}{T1}{\footnotesize{\SI{\vinkelB}{\degree}}}
   \psline[linestyle=solid,linecolor=red](C)(D)(A)(B)
  \end{pspicture}
\end{figure}

\end{document
}

I would like to cut off the yellow parallelogram if it reaches the right, vertical part of the red curve, i.e., if the rays of light hit the wall. How do I do this?

Thank you in advance!

P.S. If you spot a way to make the code (more) elegant and/or efficient, I will be glad to know.

Update:
Come to think of it, I would also like the parallelogram to be cut off if it reaches the left, vertical part of the red curve.

Update 2:
Please see the attached picture.
Attachments
angles.png
Angles for the rays to hit the floor only.
angles.png (29.58 KiB) Viewed 791 times
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
svend_tveskaeg
 
Posts: 475
Joined: Sun Jul 12th, 2009
Location: Aarhus, Denmark

Re: PSTricks | Cut off Part of Parallelogram if ...

Postby svend_tveskaeg on Sun Oct 14th, 2012

I have cross-posted this question to {TeX} SX.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
svend_tveskaeg
 
Posts: 475
Joined: Sun Jul 12th, 2009
Location: Aarhus, Denmark

Re: PSTricks | Cut off part of parallelogram if ...

Postby svend_tveskaeg on Sun Oct 14th, 2012

The user percusse has come up with a solution on {TeX} SX.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
svend_tveskaeg
 
Posts: 475
Joined: Sun Jul 12th, 2009
Location: Aarhus, Denmark

Re: PSTricks | Cut off part of parallelogram if ...

Postby CrazyHorse on Mon Oct 15th, 2012

svend_tveskaeg wrote:Consider the following MWE, illustrating rays of light coming from the Sun through the Oculus in the Pantheon, Rome:


it is easier to use a simple line for the sun ray

Code: Select all  •  Open in writeLaTeX
\documentclass[pstricks]{standalone}
\usepackage{pstricks-add}
\usepackage[locale=DE]{siunitx}

\begin{document}
\def\radius{21.65
} % Radius of the dome
\def\faktor{0.3333}
\def\vinkelA{12
}   % Width of the Oculus
\makeatletter
\pst@getsinandcos{\vinkelA}
\pstFPmul\RelRadius\faktor{\radius}
\pstFPmul\MaxLW\RelRadius\pst@sin
\pstFPmul\MaxLW{2}{\MaxLW}

\multido{\iA=10+5}{16
}{% % Angle of the Sun's rays
\psset{unit=0.5cm}
\begin{pspicture}(-\RelRadius,-\RelRadius)(\RelRadius,10)
  \pst@getsinandcos{\iA}
  \pstFPmul\RelLW{\MaxLW}{\pst@sin}
  \pnode(-\RelRadius,-\RelRadius){A}
  \pnode(-\RelRadius,0){B}
  \pnode(0,0){C}
  \pnode(\RelRadius,-\RelRadius){D}
  \pnode(!0 \RelRadius\space \vinkelA\space cos mul){T1
}
  \rput(!0 \RelRadius\space \vinkelA\space cos mul){%
        \pcline[linecolor=yellow,linewidth=\RelLW,nodesepB=-8,nodesepA=-1]%
       (0,0)(!-1 \iA\space neg Tan neg)}
  \begin{psclip}{%
    \pscustom[linewidth=2pt,linecolor=red,fillstyle=solid,fillcolor=blue!20]{%
    \psarc(C){\RelRadius}{!90 \vinkelA\space add}{180}
    \psline(B)(A)(D)
    \psarc(C){\RelRadius}{0}{!90 \vinkelA\space sub}}
}
    \rput(!0 \RelRadius\space \vinkelA\space cos mul){%
        \pcline[linecolor=yellow,linewidth=\RelLW,nodesep=-4]%
       (0,0)(!\RelRadius\space dup \iA\space neg Tan mul )}
  \end{psclip}
  \psline[linestyle=dotted]({-\RelRadius,0}|T1)({\RelRadius,0
}|T1)
  \rput(!\RelRadius\space 90 \vinkelA\space sub PtoC){%
    \pswedge(0,0){1}{!180 \iA\space sub}{180}
    \uput{1}[!180 \iA\space 2 div sub](0,0){\footnotesize\SI{\iA}{\degree}}
    \psline[linestyle=dotted](0,0)(!3 180 \iA\space sub PtoC)
  }
\end{pspicture}}

\end{document
}
Attachments
demo.gif
demo.gif (74.51 KiB) Viewed 733 times
CrazyHorse
 
Posts: 348
Joined: Sat Aug 2nd, 2008

Re: PSTricks | Cut off part of parallelogram if ...

Postby svend_tveskaeg on Mon Oct 15th, 2012

@Herbert: Awesome!
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
svend_tveskaeg
 
Posts: 475
Joined: Sun Jul 12th, 2009
Location: Aarhus, Denmark


Return to Graphics, Figures & Tables

Who is online

Users browsing this forum: Bing [Bot] and 4 guests