2

I am getting different output images when using named v/s raw coordinates in tikz-3dplot. Is there way to print out what the value of coodinates are to help debug or check any log files. Minimal example below:

\documentclass{standalone} \usepackage{tikz} \usepackage{tikz-3dplot} \usepackage{calc} \begin{document} \tdplotsetmaincoords{70}{100}%right hand \begin{tikzpicture}[scale=2] \def\xmax{2} \def\ymax{2} \def\dz{0.2} \coordinate (M) at (0.5*\xmax,0.5*\ymax,0); \draw[fill=green!40!white, opacity = 0.5,tdplot_main_coords] ({0},{0},{0}) to [out=30,in=200] ({0},{\ymax},{0}) to ({\xmax},{\ymax},{0}) to[out=200,in=30] ({\xmax},{0},{0}) to ({0},{0},{-\dz}) to (M) to (0,0,0); \end{tikzpicture} \tdplotsetmaincoords{70}{100}%right hand \begin{tikzpicture}[scale=2] \def\xmax{2} \def\ymax{2} \def\dz{0.2} \draw[fill=green!40!white, opacity = 0.5,tdplot_main_coords] ({0},{0},{0}) to [out=30,in=200] ({0},{\ymax},{0}) to ({\xmax},{\ymax},{0}) to[out=200,in=30] ({\xmax},{0},{0}) to ({0},{0},{-\dz}) to (0.5*\xmax,0.5*\ymax,0) to (0,0,0); \end{tikzpicture} \end{document} 

Ouput image

1 Answer 1

3

You did not use tdplot_main_coords when defining the symbolic coordinate M. If you replace

\coordinate (M) at (0.5*\xmax,0.5*\ymax,0); 

by

\path[tdplot_main_coords] (0.5*\xmax,0.5*\ymax,0) coordinate (M); 

both results match.

\documentclass{standalone} \usepackage{tikz} \usepackage{tikz-3dplot} \begin{document} \tdplotsetmaincoords{70}{100}%right hand \begin{tikzpicture}[scale=2] \def\xmax{2} \def\ymax{2} \def\dz{0.2} \path[tdplot_main_coords] (0.5*\xmax,0.5*\ymax,0) coordinate (M); \draw[fill=green!40!white, opacity = 0.5,tdplot_main_coords] ({0},{0},{0}) to [out=30,in=200] ({0},{\ymax},{0}) to ({\xmax},{\ymax},{0}) to[out=200,in=30] ({\xmax},{0},{0}) to ({0},{0},{-\dz}) to (M) to (0,0,0); \end{tikzpicture} \tdplotsetmaincoords{70}{100}%right hand \begin{tikzpicture}[scale=2] \def\xmax{2} \def\ymax{2} \def\dz{0.2} \draw[fill=green!40!white, opacity = 0.5,tdplot_main_coords] ({0},{0},{0}) to [out=30,in=200] ({0},{\ymax},{0}) to ({\xmax},{\ymax},{0}) to[out=200,in=30] ({\xmax},{0},{0}) to ({0},{0},{-\dz}) to (0.5*\xmax,0.5*\ymax,0) to (0,0,0); \end{tikzpicture} \end{document} 

enter image description here

The calc library, which gets automatically loaded by tikz-3dplot, allows you to compare the screen coordinates of named nodes/coordinates. The inofficial library 3dtools allows you to retrieve the coordinates that were used to define the node/coordinate but at this point does not store the information in which coordinate systems they were defined.

2
  • Thanks @Schrodingger's cat. Based on your answer I found that passing 'tdplot_main_coords' to tikzpicture like so : also ` \begin{tikzpicture}[scale=2,tdplot_main_coords].. \end{tikzpicture}` also works. Commented Nov 28, 2019 at 15:59
  • @Haaput Of course, yes. This is what one usually does, or one uses a scope. Commented Nov 28, 2019 at 16:00

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.