LaTeX forum ⇒ Graphics, Figures & TablesPSTricks | Cut off part of parallelogram if ... Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am
Location: Aarhus, Denmark

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

Postby svend_tveskaeg » Wed Oct 10, 2012 7:20 pm

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:

  1. \documentclass{article}
  2.  
  3. \usepackage{auto-pst-pdf,pst-eucl,pstricks-add}
  4. \usepackage[locale=DE]{siunitx}
  5. \usepackage{expl3}
  6.  
  7. \ExplSyntaxOn
  8. \cs_new_eq:NN
  9. \calculate
  10. \fp_eval:n
  11. \ExplSyntaxOff
  12.  
  13. \begin{document}
  14.  
  15. \def\radius{21.65 } % Radius of the dome
  16. \def\vinkelA{12 } % Width of the Oculus
  17. \def\vinkelB{71 } % Angle of the Sun's rays
  18. \def\faktor{\calculate{1/3} }
  19. \def\RelRadius{\calculate{\faktor*\radius} }
  20. \def\vinkelC{\calculate{90-\vinkelA} }
  21. \def\vinkelD{\calculate{90+\vinkelA} }
  22. \def\vinkelE{\calculate{180+\vinkelC} }
  23. \def\vinkelF{\calculate{180+\vinkelD} }
  24. \def\vinkelG{\calculate{180-\vinkelB} }
  25. \def\vinkelH{\calculate{180+\vinkelG} }
  26. \begin{figure}
  27. \centering
  28. \begin{pspicture}(44,50)
  29. \psset{unit=0.5cm,linecolor=red}
  30. \pnode(0,0){A}
  31. \pnode(!0 \RelRadius){B}
  32. \pnode(!2 \RelRadius mul \RelRadius){C}
  33. \pnode(!2 \RelRadius mul 0){D}
  34. \pnode(!\RelRadius \RelRadius){E}
  35. \psarc(E){\RelRadius}{0}{\vinkelC}
  36. \psarc(E){\RelRadius}{\vinkelD}{180}
  37. \psset{linestyle=none,linecolor=black,dotsep=2pt}
  38. \psRelLine[angle=\vinkelF](E)(B){1}{P1}
  39. \psRelLine[angle=\vinkelE](E)(B){1}{P2}
  40. \psRelLine[angle=\vinkelG](P1)(P2){1}{L1}
  41. \psRelLine[angle=\vinkelH,linestyle=dotted](P2)(P1){1}{L2}
  42. \psRelLine[angle=\vinkelG](P2)(P1){1 \vinkelA cos add 2 \vinkelA sin mul \vinkelB sin mul div}{L3}
  43. \psParallelLine(L2)(L3)(L1){1}{L4}
  44. \pspolygon[fillstyle=solid,fillcolor=yellow](L1)(L2)(L3)(L4)
  45. \pnode(!0 1 \vinkelA cos add \RelRadius mul){T1}
  46. \pnode(!2 \RelRadius mul 1 \vinkelA cos add \RelRadius mul){T2}
  47. \pcline[linestyle=dotted](T1)(T2)
  48. \pstMarkAngle[linestyle=solid,MarkAngleRadius=0.8,LabelSep=1.5,arrows=<->]{L2}{P2}{T1}{\footnotesize{\SI{\vinkelB}{\degree}}}
  49. \psline[linestyle=solid,linecolor=red](C)(D)(A)(B)
  50. \end{pspicture}
  51. \end{figure}
  52.  
  53. \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 1384 times
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Link:
BBcode: Topic is solved[/url]" title="Click to select post's link in BBcode format" onclick="this.focus();this.select();" />
HTML: Topic is solved</a>" title="Click to select post's link in HTML format" onclick="this.focus();this.select();" />
Hide post links
Show post links

User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am
Location: Aarhus, Denmark

Postby svend_tveskaeg » Sun Oct 14, 2012 12:31 am

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)

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am
Location: Aarhus, Denmark

Postby svend_tveskaeg » Sun Oct 14, 2012 8:49 pm

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)

Link:
BBcode:
HTML:
Hide post links
Show post links

CrazyHorse
Posts: 350
Joined: Sat Aug 02, 2008 8:47 am

Postby CrazyHorse » Mon Oct 15, 2012 2:53 pm

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

  1. \documentclass[pstricks]{standalone}
  2. \usepackage{pstricks-add}
  3. \usepackage[locale=DE]{siunitx}
  4.  
  5. \begin{document}
  6. \def\radius{21.65} % Radius of the dome
  7. \def\faktor{0.3333}
  8. \def\vinkelA{12} % Width of the Oculus
  9. \makeatletter
  10. \pst@getsinandcos{\vinkelA}
  11. \pstFPmul\RelRadius\faktor{\radius}
  12. \pstFPmul\MaxLW\RelRadius\pst@sin
  13. \pstFPmul\MaxLW{2}{\MaxLW}
  14.  
  15. \multido{\iA=10+5}{16}{% % Angle of the Sun's rays
  16. \psset{unit=0.5cm}
  17. \begin{pspicture}(-\RelRadius,-\RelRadius)(\RelRadius,10)
  18. \pst@getsinandcos{\iA}
  19. \pstFPmul\RelLW{\MaxLW}{\pst@sin}
  20. \pnode(-\RelRadius,-\RelRadius){A}
  21. \pnode(-\RelRadius,0){B}
  22. \pnode(0,0){C}
  23. \pnode(\RelRadius,-\RelRadius){D}
  24. \pnode(!0 \RelRadius\space \vinkelA\space cos mul){T1}
  25. \rput(!0 \RelRadius\space \vinkelA\space cos mul){%
  26. \pcline[linecolor=yellow,linewidth=\RelLW,nodesepB=-8,nodesepA=-1]%
  27. (0,0)(!-1 \iA\space neg Tan neg)}
  28. \begin{psclip}{%
  29. \pscustom[linewidth=2pt,linecolor=red,fillstyle=solid,fillcolor=blue!20]{%
  30. \psarc(C){\RelRadius}{!90 \vinkelA\space add}{180}
  31. \psline(B)(A)(D)
  32. \psarc(C){\RelRadius}{0}{!90 \vinkelA\space sub}}}
  33. \rput(!0 \RelRadius\space \vinkelA\space cos mul){%
  34. \pcline[linecolor=yellow,linewidth=\RelLW,nodesep=-4]%
  35. (0,0)(!\RelRadius\space dup \iA\space neg Tan mul )}
  36. \end{psclip}
  37. \psline[linestyle=dotted]({-\RelRadius,0}|T1)({\RelRadius,0}|T1)
  38. \rput(!\RelRadius\space 90 \vinkelA\space sub PtoC){%
  39. \pswedge(0,0){1}{!180 \iA\space sub}{180}
  40. \uput{1}[!180 \iA\space 2 div sub](0,0){\footnotesize\SI{\iA}{\degree}}
  41. \psline[linestyle=dotted](0,0)(!3 180 \iA\space sub PtoC)
  42. }
  43. \end{pspicture}}
  44.  
  45. \end{document}
Attachments
demo.gif
demo.gif (74.51 KiB) Viewed 1326 times

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am
Location: Aarhus, Denmark

Postby svend_tveskaeg » Mon Oct 15, 2012 4:43 pm

@Herbert: Awesome!
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 6 guests