This question led to a new library in TikZ:
perspective
(PGF manual, chapter 63)
I have a 3d object created with inkscape
as shown below:
Now I am trying to place a text in the same orientation as the light-blue colored area. However, I want to insert the text with latex
instead of directly embedding it in the pdf
(hence, I save it with pdf+Latex
option in inkscape
).
But when I try to insert the text in the 3d area, I get:
How can I get OMEAG
aligned parallely to the light-blue region.
I could not attach the pdf of it, however the MWE
is below:
%&lualatex
% !TeX program = lualatex
\documentclass[11pt,a4paper]{article}
%\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{pgfplots}
\usepackage{pstricks} %for embedding pspicture.
\pgfplotsset{compat=newest}
\usepackage{tikz}
\begin{document}
\begin{figure}[h]
\centering{
\input{drawing4.pdf_tex}
\caption{Top view.}
\label{fig:aktomnpView}
}
\end{figure}
\end{document}
and \input{drawing4.pdf_tex}
is below:
\begingroup%
\makeatletter%
\providecommand\color[2][]{%
\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}%
\renewcommand\color[2][]{}%
}%
\providecommand\transparent[1]{%
\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}%
\renewcommand\transparent[1]{}%
}%
\providecommand\rotatebox[2]{#2}%
\newcommand*\fsize{\dimexpr\f@size pt\relax}%
\newcommand*\lineheight[1]{\fontsize{\fsize}{#1\fsize}\selectfont}%
\ifx\svgwidth\undefined%
\setlength{\unitlength}{303.69978591bp}%
\ifx\svgscale\undefined%
\relax%
\else%
\setlength{\unitlength}{\unitlength * \real{\svgscale}}%
\fi%
\else%
\setlength{\unitlength}{\svgwidth}%
\fi%
\global\let\svgwidth\undefined%
\global\let\svgscale\undefined%
\makeatother%
\begin{picture}(1,1.35089637)%
\lineheight{1}%
\setlength\tabcolsep{0pt}%
\put(0,0){\includegraphics[width=\unitlength,page=1]{drawing4.pdf}}%
\put(0.54334545,0.71256022){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}OMEAG\end{tabular}}}}%
\end{picture}%
\endgroup%
Best Answer
Edit 3
I'm happy to announce that some of the code of this answer is now included in the Tikz package (v3.1.2) as the
perspective
library.Edit 2
Using this awesome answer in combination with my
tpp
coordinate system, I managed to get an approximation of a nonlinear mapping to the side of the block.Or without help lines:
Stationary image:
MWE:
Edit See previous edits for my former answer
I defined a new coordinate system
three point perspective
. It can be used asOr slightly more convenient
To turn perspective view on, you can call the
perspective={<options>}
Tikz-key. The options are:p={(p_x,p_y,p_z)}
to set the vanishing point inx
direction, to turn of setp_x
to 0.q={(q_x,q_y,q_z)}
to set the vanishing point iny
direction, to turn of setq_y
to 0.r={(r_x,r_y,r_z)}
to set the vanishing point inz
direction, to turn of setr_z
to 0.The default perspective is set to
p={(15,0,0)},q={(0,15,0)},r={(0,0,50)}
.To change the viewing angle, I also added a
view={<rotate about x>}{<rotate about z>}
key. The latter ensures that I don't need thetikz-3dplot
any longer.The result is similar, but is easier to use.
Of course I had to make an animation to show different vanishing point distances:
MWE animation:
Appendix: Two point perspective theory
A perspective transformation with two vanishing points can be described with a four by four transformation matrix H which is a function of the two vanishing points p with
p_x <> 0
, and r withr_y <> 0
.You can build H as follows
To be able to transform a point x expressed in 3D with H, it must be expressed in a projected space, which can be written as
Any multiplication (elongation of the 4D vector) of a vector in projected space with a non-zero scalar alpha, still maps to the same point in 3D space. E.g., the following two points map to the same point in 3D space:
So to get the three coordinates of the 3D point, you can divide all entries by the fourth entry (we need this after multiplication with a transformation matrix as H).