1

I'm trying to define that dynamic coordinate which specifies also Xxy,Xxz,Xyz plain coordinates etc. However, such coordinate seems to be with different length scale than my coordinate system is.

\documentclass[a4paper,fleqn,leqno]{article}
\usepackage{tikz,tikz-3dplot}
\usetikzlibrary{arrows.meta,decorations.markings}
\begin{document}
\begin{tikzpicture}[cm={-1,-1,1,0,(0,0)},x=3.85mm,z=-1cm]
\draw[-{Classical TikZ Rightarrow[scale=1.2]},very thick] (-2,0,0) -- (5,0,0) node[anchor=north,xshift=-3pt] {$x$}; 
\draw[-{Classical TikZ Rightarrow[scale=1.2]},very thick] (0,-2,0) -- (0,5,0) node[anchor=west] {$y$};
\draw[-{Classical TikZ Rightarrow[scale=1.2]},very thick] (0,0,-2) -- (0,0,5) node[anchor=south] {$z$};
\tdplotsetcoord{X}{1}{2}{3}
\coordinate (Y) at (1,2,3);
\draw[-{Stealth[scale=1.5,width=3pt]},color=gray,semithick] (O,0,0) -- (X);
\draw[dashed,color=red] (O,0,0) -- (Xxy);
\end{tikzpicture}
\end{document}

I would like X coordinate to be at same place as Y coordinate, defined the same way (1,2,3).
If it is placed in polar coord. system, does there exist any transformation macro or another way to define Xxy,Xxz,Xyz with Cartesian coordinates? Or do I have to create the transformation myself?

1
  • I've tried the easiest way of transformation \def\Xx{1} \def\Xy{2} \def\Xz{3} \tdplotsetcoord{X}{\sqrt{\Xx^{2}+\Xy^{2}+\Xz^{2}}}{...}{...} The compiler though cannot stand the math expression. If I skip the closing parenthesis as advised, the errors vanish but so the outcome. How can be math expression correctly inserted? Thanks.
    – user46581
    Jul 29 '14 at 9:08
0

This is the source of \tdplotsetcoord of the tikz-3dplot package

\newcommand{\tdplotsetcoord}[4]{%
%
%do some trig to determine angular part of coordinate
\tdplotsinandcos{\sinthetavec}{\costhetavec}{#3}%
\tdplotsinandcos{\sinphivec}{\cosphivec}{#4}%
\tdplotmult{\stcpv}{\sinthetavec}{\cosphivec}%
\tdplotmult{\stspv}{\sinthetavec}{\sinphivec}%
%
%assign the point
\coordinate (#1) at ($#2*(\stcpv,\stspv,\costhetavec)$);
%assign the xy, xz, and yz projections of the point
\coordinate (#1xy) at ($#2*(\stcpv,\stspv,0)$);
\coordinate (#1xz) at ($#2*(\stcpv,0,\costhetavec)$);
\coordinate (#1yz) at ($#2*(0,\stspv,\costhetavec)$);
%assign the x, y, and z projections of the point
\coordinate (#1x) at ($#2*(\stcpv,0,0)$);
\coordinate (#1y) at ($#2*(0,\stspv,0)$);
\coordinate (#1z) at ($#2*(0,0,\costhetavec)$);
}

To use cartesian coordinates, you can use

\newcommand{\tdplotsetcoordcart}[4]{%
%assign the point
\coordinate (#1) at (#2,#3,#4);
%assign the xy, xz, and yz projections of the point
\coordinate (#1xy) at (#2,#3,0);
\coordinate (#1xz) at (#2,0,#4);
\coordinate (#1yz) at (0,#3,#4);
%assign the x, y, and z projections of the point
\coordinate (#1x) at (#2,0,0);
\coordinate (#1y) at (0,#3,0);
\coordinate (#1z) at (0,0,#4);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.