summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/rendering/pgfrenderpoints.code.tex
blob: 48d36bae8bfce4f985340121a8f7f1341298d9e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
% Copyright 2006 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.

\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/rendering/pgfrenderpoints.code.tex,v 1.2 2007/03/09 17:49:33 tantau Exp $





% Create a 3D point
%  
% #1       = macro name in which the point object should be stored 
% #2 to #4 = x-, y- and z-coordinate of the point 
%  
% Note:
%
% The quick version does not call \setlength and is faster.
%
% Example:
%
% \pgfrenderpointcreate{\pgfpoint{2pt+3cm}{3cm}}

\def\pgfrenderpointcreate#1#2#3#4{%
  \pgfmathsetlength\pgf@xa{#2}%
  \pgfmathsetlength\pgf@xb{#3}%
  \pgfmathsetlength\pgf@xc{#4}%
  \pgfqrenderpointcreate{\the\pgf@xa}{\the\pgf@xb}{\the\pgf@xc}%
}

\def\pgfqrenderpointcreate#1#2#3#4{%
  \edef#1{\pgf@xa=#2\relax\pgf@xb=#3\pgf@xc=#4\relax}%
}

\def\pgf@render@unpack#1{%
  #1%
}


% The origin point object
%  
% Description:
%
% This object is always the origin.
%  

\pgfqrenderpointcreate\pgfrenderobjorigin{0pt}{0pt}{0pt}




% Add two 3D vectors
%  
% #1 = name of new vector (may be one of the input)
% #2 = name of first vector
% #3 = name of second vector
%  
% Description:
%
% The points #2 and #3 are added and the result is stored in #1. If #1
%  equals either #2 or #3, to point is overwritten.
%
% Example:
%
% \pgfrenderpointcreate{\myvec}{1cm}{2cm}{3cm}
% \pgfrenderpointcreate{\offset}{1cm}{0cm}{0cm}
% \pgfrenderpointadd{\myvec}{\myvec}{\offset}

\def\pgfrenderpointadd#1#2#3{%
  \pgf@render@unpack#2%
  \pgf@ya=\pgf@xa%
  \pgf@yb=\pgf@xb%
  \pgf@yc=\pgf@xc%
  \pgf@render@unpack#3%
  \advance\pgf@xa by\pgf@ya%
  \advance\pgf@xb by\pgf@yb%
  \advance\pgf@xc by\pgf@yc%
  \pgfqrenderpointcreate#1{\the\pgf@xa}{\the\pgf@xb}{\the\pgf@xc}%
}


% Scale a 3D vectors
%  
% #1 = name of new vector (may be one of the input)
% #2 = scale
% #3 = name of vector to be scaled
%  
% Description:
%
% Sets #1 := #2*#3.
%
% Example:
%
% \pgfrenderpointcreate{\myvec}{1cm}{2cm}{3cm}
% \pgfrenderpointscale{\myvec}{2}{\myvec}

\def\pgfrenderpointscale#1#2#3{%
  \pgf@render@unpack#3%
  \pgf@xa=#2\pgf@xa%
  \pgf@xb=#2\pgf@xb%
  \pgf@xc=#2\pgf@xc%
  \pgfqrenderpointcreate#1{\the\pgf@xa}{\the\pgf@xb}{\the\pgf@xc}%
}




% Project a 3D point to 2D
%  
% #1 = 3D point object
%
% Description:
%
% This command takes a 3D point object and sets \pgf@x to the x-value
% of the point and \pgf@y to the y-value.
%  
% Example:
%
% \pgfpointprojection{\mypoint}

\def\pgfpointprojection#1{%
  \pgf@render@unpack{#1}%
  \pgf@x=\pgf@xa%
  \pgf@y=\pgf@ya%
}







\endinput