I want to draw sphere with centre at O(0,0,0) and passing the point A(2,3,6). I tried
xxxxxxxxxx
\documentclass[border=2mm,12pt,tikz]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{calc}
\begin{document}
\tdplotsetmaincoords{60}{70}
\begin{tikzpicture}[tdplot_main_coords]
\path
(0,0,0) coordinate (O)
(2,3,6) coordinate (T);
\draw[tdplot_screen_coords] (O) let \p1 = ($ (T) - (O) $) in circle ({veclen(\x1,\y1,\z1)});
\end{tikzpicture}
\end{document}
I can not get the result. Where is wrong in that code?
The veclen
function only takes two arguments. However, it is possible to define pgf functions that take arbitrarily many arguments. Existing examples include the max
function, which in its original version also was restricted to two arguments. Using the the definition of max
I define a function Veclen
which takes arbitrarily many arguments.
Please note that the currently existing function veclen
has other deficiencies. It cannot be switched to fpu mode. It may thus be worthwhile to place a feature request to change it to something along the lines outlined above.
Another feature request would be to record the screen depth of each coordinate. Currently, tikz
has access to the screen coordinates only. It is, in principle, possible to computed and record the screen depth. However, it is very unlikely that such a feature request will be successful.
However, you could use the fact that functions declared with declare function
can also be arrays. So you can access the components and use them for operations such as the computation of a distance.