% 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{pgfrenderpoints.code.tex}





% 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
