Debian Codegraph @

texmf-dist/tex/latex/sunpath/sunpath.sty

raw
1 %%
2 %% This is file `sunpath.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% sunpath.dtx (with options: `package')
8 %%
9 \NeedsTeXFormat{LaTeX2e}[2022/11/01]
10 \ProvidesPackage{sunpath}[2024/10/20 v0.5 Draw Sun Path]
11
12
13 \RequirePackage{expl3}
14 \RequirePackage{tikz}
15 \usetikzlibrary{calc,math,through}
16
17
18 \pgfkeys{/tikz/.cd,
19 spradius/.store in=\spradius,
20 spradius=5.5,
21 altitude mapping/.store in = \altmapping,
22 altitude mapping=spherical
23 }
24
25 \makeatletter
26
27 \tikzset{
28 cs/azi/.store in=\tikz@cs@azi,
29 cs/alt/.store in=\tikz@cs@alt,
30 }
31
32 \tikzset{
33 declare function = {
34 spherical(\alt) = \spradius * cos(\alt);
35 equidistance(\alt) = \spradius - \spradius*abs(\alt)/90;
36 altradius(\alt) = \altmapping(\alt);
37 aziangle(\x) = 90 - \x;
38 }
39 }
40
41 \tikzdeclarecoordinatesystem{sunpath}%
42 {
43 \tikzset{cs/.cd,azi=0,alt=0,#1}
44 \tikzmath{
45 \r = altradius(\tikz@cs@alt);
46 \angle = aziangle(\tikz@cs@azi);
47 }
48 \pgfpointadd{\pgfpointxy{0}{0}}{%
49 \pgfpointpolarxy{\angle}{\r}
50 }
51 }
52 \makeatother
53
54 \tikzset{
55 sunpath grid/.style={help lines,color=blue!45!white!80},
56 sunpath tick/.style={draw,thick,color=blue!90!white!80},
57 sunpath minor tick/.style={draw,thin,color=blue!90!white!80},
58 altitude label/.style={
59 font=\footnotesize\sffamily,
60 fill=white,minimum width={width("90")+2pt},
61 inner sep=0.5pt
62 },
63 azimuth label/.style={
64 font=\footnotesize\sffamily,
65 minimum width={width("360")+2pt},
66 inner sep=0.5pt
67 },
68 direction label/.style={
69 font=\normalsize\rmfamily
70 }
71 }
72
73
74 \NewDocumentCommand\spcrosshair{O{sunpath grid}}{
75 \draw[#1] (-\spradius,0) -- (\spradius,0);
76 \draw[#1] (0,-\spradius) -- (0,\spradius);
77 }
78
79 \NewDocumentCommand\spgeodirection{O{22pt} O{direction label}}{
80 \foreach \dname / \dgrad in {N/0, E/90, S/180, W/270}{
81 \tikzmath{
82 \polarangle = aziangle(\dgrad);
83 }
84 \coordinate (D) at (\polarangle:\spradius cm + #1);
85 \node[#2,anchor=270-\dgrad] at (D) {\dname};
86 }
87 }
88
89 \NewDocumentCommand\spaltitudecircle{m O{sunpath grid}}{
90 \foreach \altitude in #1 {
91 \coordinate (A) at (sunpath cs:azi=0,alt=\altitude) ;
92 \path[draw,sunpath grid] (0,0) circle[radius=altradius(\altitude)];
93 }
94 }
95
96 \NewDocumentCommand\spaltitudelabel{m O{135} O{altitude label}}{
97 \foreach \altitude in #1 {
98 \coordinate (A) at (sunpath cs:azi=#2,alt=\altitude) ;
99 \node [anchor=east,#3] at (A) {\altitude};
100 }
101 }
102
103 \NewDocumentCommand\spazimuthlabel{m O{azimuth label}}{
104 \foreach \azimuth in #1 {
105 \tikzmath{
106 \polarangle = aziangle(\azimuth);
107 }
108 \coordinate (D) at (\polarangle:\spradius cm + 13pt);
109 \node[#2] at (D) {\azimuth};
110 }
111 }
112
113 \NewDocumentCommand\spazimuthline{m m m}{
114 \foreach \azimuth in #1{
115 \draw[sunpath grid]
116 (sunpath cs:azi=\azimuth,alt={#2}) -- (sunpath cs:azi=\azimuth,alt={#3});
117 }
118 }
119
120 \NewDocumentCommand\spazimuthtick{O{6pt} O{2.5pt} O{5pt}}{
121 \foreach \azimuth in {10,20,...,360}{
122 \tikzmath{
123 \pa = aziangle(\azimuth);
124 }
125 \path[sunpath tick] (\pa:\spradius) -- (\pa:{\spradius cm + #1});
126 }
127
128 \foreach \azimuth in {1,2,...,360}{
129 \tikzmath{
130 \pa = aziangle(\azimuth);
131 }
132 \path[sunpath minor tick] (\pa:\spradius) -- (\pa:{\spradius cm + #2});
133 }
134
135 \foreach \azimuth in {15,45,...,345}{
136 \tikzmath{
137 \pa = aziangle(\azimuth);
138 }
139 \path[sunpath minor tick] (\pa:\spradius) -- (\pa:{\spradius cm + #3});
140 }
141 }
142
143 %%%%%%%%%%%%%%
144 %% Copyright (C) 2024 by
145 %% Hong-Phuc Bui
146 %%
147 %% It may be distributed and/or modified under the conditions of
148 %% the LaTeX Project Public License (LPPL), either version 1.3c of
149 %% this license or (at your option) any later version. The latest
150 %% version of this license is in the file:
151 %%
152 %% https://www.latex-project.org/lppl.txt
153 %%
154 %%
155 %% This work consists of the files sunpath.dtx,
156 %% sunpath.ins,
157 %% and the derived files sunpath.pdf,
158 %% sunpath.sty.
159 %%
160 %%
161 %% End of file `sunpath.sty'.