I found this answer from the User Caramdir and am actually trying to fit the code to my needs. There's something like this
\newcommand\definePointByXYZ[4]{
%\coordinate (#1) at (#2,#3,#4);
\expandafter\gdef\csname tsx@point@#1\endcsname{
\def\tsx@point@x{#2}
\def\tsx@point@y{#3}
\def\tsx@point@z{#4}
}
}
% Define a plane.
% #1 = name of the plane
% #2*x + #3*y + #4*z = #5 is the equation of the plane
\newcommand*\definePlaneByEquation[5]{
\expandafter\gdef\csname tsx@plane@#1\endcsname{
\def\tsx@plane@xcoeff{#2}
\def\tsx@plane@ycoeff{#3}
\def\tsx@plane@zcoeff{#4}
\def\tsx@plane@scalar{#5}
}
}
% Project a point to a plane.
% #1 = name of the new point
% #2 = name of old point
% #3 = name of plane
\newcommand\projectPointToPlane[3]{{
\csname tsx@point@#2\endcsname
\csname tsx@plane@#3\endcsname
% ...
}}
In the command projectPointToPlane the arguments are two points that get defined by \definePointByXYZ and then it's possible to calculate anything, for example:
\pgfmathparse{\tsx@plane@xcoeff*\tsx@plane@xcoeff + \tsx@plane@ycoeff*\tsx@plane@ycoeff + \tsx@plane@zcoeff*\tsx@plane@zcoeff}
\let\nnormsq\pgfmathresult
Now I'd like to create something like this
% #1 = Name of the object
% #2 = Point A
% #2 = Point B
\newcommand*\mynewcommand[3]{
\csname tsx@point@#2\endcsname
\csname tsx@point@#3\endcsname
% Calculate something
\pgfmathsetmacro{\myvariable}{%any expression}
}
My Question: How can I calculate with the coordinates of two Points? Is it even possible? My first try was to rename one line to \csname tsx@pointtwo@#3\endcsname and then
\pgfmathsetmacro{\myvariable}{\tsx@point@x *\tsxpointtwo@x}
but that didn't work. I'm new to TeX-Programming, so any help is really appreciated. :)
xyvalues from them using\newdim\mypointx \pgfextractx\mypointx{\pgfpointachor{PointA}{center}}, the same fory, then you can use\mypointxand\mypointyin your calculations. If "Point A" and B are something else, then what are they exactly? – Guilherme Zanotelli Jan 18 '17 at 16:49\definePointByXYZ. For example:\definePointByXYZ{A}{1}{2}{3}and\definePointByXYZ{B}{1}{4}{2}defines points named A and B with the coordinates x=1,y=2,z=3 and x=1,y=4,z=2. Then I can use\mynewcommand{...}{A}{B}. Now I want to calculate with the coordinates of the both points inside my\mynewcommandsimilar to\projectPlaneToPointfrom the linked answer. – joni Jan 19 '17 at 09:01