1

To use the three point perspective coordinate systems, one has to use the syntax

(tpp cs:x=1,y=2,z=3)

to specify the point (1,2,3). I find this a bit cumbersome to write. Is there a way to automatically treat coordinates of the form (1,2,3) as coordinates in the three point perspective coordinate system?

I know that I could try to define a new command which translates \tpp{1,2,3} into (tpp cs:x=1,y=2,z=3).

red_trumpet
  • 995
  • 1
  • 6
  • 17
  • Related: https://tex.stackexchange.com/questions/352849/how-to-set-a-user-defined-coordinate-system-globally – gernot Dec 05 '23 at 14:24

1 Answers1

5

We can introduce a key 3d coordinate is with the choice

  • default (→ \pgfpointxyz) and
  • perspective (→ \pgfpointperspectivexyz).

You just have to use the right choice at the right time.

The red node should not use the perspective coordinate system but you can use 3d coordinate is = default for it or the explicit (xyz cs: x=4, y=0, z=0).

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{perspective}
\makeatletter
\tikzset{
  3d coordinate is/.is choice,
  3d coordinate is/default/.code={\def\tikz@parse@splitxyz##1##2##3,##4,{%
    \def\pgfutil@next{##1{\pgfpointxyz{##2}{##3}{##4}}}}},
  3d coordinate is/perspective/.code={\def\tikz@parse@splitxyz##1##2##3,##4,{%
    \def\pgfutil@next{##1{\pgfpointperspectivexyz{##2}{##3}{##4}}}}}}
\makeatother
\begin{document}
\begin{tikzpicture}[isometric view, perspective={p = {(4,0,0)}, q = {(0,4,0)}}]
\node[fill=red,circle,inner sep=1.5pt,label=above:p] at (4,0,0){};
\foreach \i in {0,...,100}
  \filldraw[fill = gray]               (tpp cs: x=\i,     y=0, z=0)
    -- (tpp cs: x=\i+0.5, y=0, z=0) -- (tpp cs: x=\i+0.5, y=2, z=0)
    -- (tpp cs: x=\i,     y=2, z=0) -- cycle;
\end{tikzpicture}
\begin{tikzpicture}[
  isometric view,
  perspective={p = {(4,0,0)}, q = {(0,4,0)}},
  3d coordinate is = perspective]
\node[fill=red,circle,inner sep=1.5pt,label=above:p] at (xyz cs: x=4, y=0, z=0){};
\foreach \i in {0,...,100}
  \filldraw[fill = gray] (\i,     0, 0)
    -- (\i+0.5, 0, 0) -- (\i+0.5, 2, 0)
    -- (\i,     2, 0) -- cycle;
\end{tikzpicture}
\end{document}

enter image description here

Sebastiano
  • 54,118
Qrrbrbirlbel
  • 119,821