Olá a todos, preciso dimensionar uma imagem do tikz, então fiz isso, \begin{tikzpicture}[scale=<factor>]
mas as fotos não são dimensionadas de acordo (é relatado no TikzManualseção 18.2 A sintaxe do Pic). Também quero fotos dimensionadas, então tentei a sintaxe, \begin{tikzpicture}[scale=0.4,every pic/.style={transform shape}]
mas não funcionou. Usando transform shape como opção de cada foto, ou seja, \pic[angle radius=5.3cm,transform shape]
está tudo bem, mas não quero usá-lo em todas as opções de \pic
s. Talvez seja um problema apenas com a biblioteca de ângulos (não tentei com outras fotos). Aqui estão meus MWEs, isso não funciona como esperado
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,angles}
\begin{document}
%rotate vectors
\begin{tikzpicture}[vector/.style={thick,-stealth},scale=0.4,every pic/.style={transform shape}]
%drawing help lines
\newcommand*{\xmin}{-3}\newcommand*{\xmax}{4}
\newcommand*{\ymin}{-5}\newcommand*{\ymax}{1}
\draw[help lines](\xmin,\ymin)grid(\xmax,\ymax);
%vector coordinates and labels
\coordinate[label={above:$v$}] (O)at (0,0);
\coordinate (vec1)at (1,-2);
\coordinate (vec2)at(4,-1);
\draw[vector] (O)--(vec1)coordinate[label={[below]$u_1$}](u1);
%sum (vec1)+(vec2)
\draw[vector,very thick,blue](O)--($(vec1)+(vec2)$)coordinate(u1+u2);
%rotated sum (u1)+(u2) -> u'1+u'2
\draw[vector,very thick,orange](O)--([rotate=-90]u1+u2)coordinate(u'1+u'2);
%rotated vectors
\draw[red,vector] (0,0)--([rotate=-90]vec1)coordinate[label={[left]$u'_1$}](u'1);
%
\draw[red,vector] (0,0)--([rotate=-90]vec2)coordinate[label={[below]$u'_2$}](u'2);
%angles between vectors by angles library, issue with angle radius=
%default angle radius=1cm and it does not scale accordingly
\pic[draw=gray] {angle = u'1--O--u'2};
% rotation traces
\pic[draw=red,dashed,<-,angle radius=1.8cm]{angle=u'1--O--vec1};
\pic[draw=blue,dashed,<-,angle radius=5.3cm,] {angle=u'1+u'2--O--u1+u2};
%vector sums labels
\coordinate[label={below:$w$}]() at(u1+u2);
\coordinate[label={below:$w'$}] ()at(u'1+u'2);
% outgoing vector scaled accordingly but I'd rather prefer not
\path[draw,fill=white] (O)circle[radius=2pt];
\path[fill] (O)circle[radius=1pt];
\end{tikzpicture}\end{document}
O seguinte funciona corretamente,
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,angles}
\begin{document}
%
%rotate vectors
\begin{tikzpicture}[vector/.style={thick,-stealth},scale=0.4 ] %every pic/.append style={transform shape}
%drawing help lines
\newcommand*{\xmin}{-3}\newcommand*{\xmax}{4}
\newcommand*{\ymin}{-5}\newcommand*{\ymax}{1}
\draw[help lines](\xmin,\ymin)grid(\xmax,\ymax);
%vector coordinates and labels
\coordinate[label={above:$v$}] (O)at (0,0);
\coordinate (vec1)at (1,-2);
\coordinate (vec2)at(4,-1);
\draw[vector] (O)--(vec1)coordinate[label={[below]$u_1$}](u1);
%sum (vec1)+(vec2)
\draw[vector,very thick,blue](O)--($(vec1)+(vec2)$)coordinate(u1+u2);
%rotated sum (u1)+(u2) -> u'1+u'2
\draw[vector,very thick,orange](O)--([rotate=-90]u1+u2)coordinate(u'1+u'2);
%rotated vectors
\draw[red,vector] (0,0)--([rotate=-90]vec1)coordinate[label={[left]$u'_1$}](u'1);
%
\draw[red,vector] (0,0)--([rotate=-90]vec2)coordinate[label={[below]$u'_2$}](u'2);
%angles between vectors by angles library, issue with angle radius=
%default angle radius=1cm and it does not scale accordingly
\pic[transform shape,draw=gray] {angle = u'1--O--u'2};
% rotation traces
\pic[draw=red,dashed,<-,angle radius=1.8cm,transform shape]{angle=u'1--O--vec1};
\pic[transform shape,draw=blue,dashed,<-,angle radius=5.3cm,] {angle=u'1+u'2--O--u1+u2};
%vector sums labels
\coordinate[label={below:$w$}]() at(u1+u2);
\coordinate[label={below:$w'$}] ()at(u'1+u'2);
% outgoing vector scaled accordingly but I'd rather prefer not
\path[draw,fill=white] (O)circle[radius=2pt];
\path[fill] (O)circle[radius=1pt];
\end{tikzpicture}
\end{document}
Talvez haja uma maneira melhor de conseguir isso, estou aberto a isso, mas não mudaria meu código do zero.
Tentei com every pic/.append style={transform shape}
mas sem resultado aparente. Como efeito colateral, o raio devetor de saídanas últimas linhas do código é dimensionado, o que não quero.
Responder1
Como você deseja anexar um estilo a cada \pic{angle}
, você pode definir pics/angle/.append style={/tikz/transform shape}
(você precisa indicar o caminho explicitamente, porque está dentro do \pic
"diretório de caminho" aqui):
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, angles}
\begin{document}
%rotate vectors
\begin{tikzpicture}[
vector/.style={thick,-stealth},
scale=0.4,
pics/angle/.append style={/tikz/transform shape}
]
%drawing help lines
\newcommand*{\xmin}{-3}\newcommand*{\xmax}{4}
\newcommand*{\ymin}{-5}\newcommand*{\ymax}{1}
\draw[help lines] (\xmin,\ymin) grid (\xmax,\ymax);
%vector coordinates and labels
\coordinate[label={above:$v$}] (O) at (0,0);
\coordinate (vec1) at (1,-2);
\coordinate (vec2) at (4,-1);
\draw[vector] (O) -- (vec1)
coordinate[label={[below]$u_1$}] (u1);
%sum (vec1)+(vec2)
\draw[vector,very thick,blue] (O)--($(vec1)+(vec2)$)
coordinate (u1u2);
%rotated sum (u1)+(u2) -> u'1+u'2
\draw[vector,very thick,orange] (O)--([rotate=-90]u1u2)
coordinate (u'1u'2);
%rotated vectors
\draw[red,vector] (0,0) -- ([rotate=-90]vec1)
coordinate[label={[left]$u'_1$}] (u'1);
%
\draw[red,vector] (0,0) -- ([rotate=-90]vec2)
coordinate[label={[below]$u'_2$}] (u'2);
%angles between vectors by angles library, issue with angle radius=
%default angle radius=1cm and it does not scale accordingly
\pic[draw=gray] {angle={u'1--O--u'2}};
% rotation traces
\pic[draw=red, dashed, <-, angle radius=1.8cm] {angle={u'1--O--vec1}};
\pic[draw=blue, dashed, <-, angle radius=5.3cm] {angle={u'1u'2--O--u1u2}};
%vector sums labels
\coordinate[label={below:$w$}] (w) at (u1u2);
\coordinate[label={below:$w'$}] (w') at (u'1u'2);
% outgoing vector scaled accordingly but I'd rather prefer not
\path[draw, fill=white] (O) circle[radius=2pt];
\path[fill] (O) circle[radius=1pt];
\end{tikzpicture}
\end{document}
Alterei alguns nomes das coordenadas porque não tenho certeza se um +
nome é uma boa ideia. Sinta-se à vontade para aderir a isso ou não.
Se você não quiser que os círculos (O)
sejam dimensionados, crie um \pic
a partir disso. Sabemos que \pic
s não são afetados pela escala e pics/angle/.append style={/tikz/transform shape}
aplicamos transform shape
apenas ao \pic{angle}
.
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, angles}
\begin{document}
%rotate vectors
\begin{tikzpicture}[
vector/.style={thick,-stealth},
scale=0.4,
pics/angle/.append style={/tikz/transform shape},
pics/origin/.style={
code={
\path[draw, fill=white] (0,0) circle[radius=2pt];
\path[fill] (0,0) circle[radius=1pt];
}
}
]
%drawing help lines
\newcommand*{\xmin}{-3}\newcommand*{\xmax}{4}
\newcommand*{\ymin}{-5}\newcommand*{\ymax}{1}
\draw[help lines] (\xmin,\ymin) grid (\xmax,\ymax);
%vector coordinates and labels
\coordinate[label={above:$v$}] (O) at (0,0);
\coordinate (vec1) at (1,-2);
\coordinate (vec2) at (4,-1);
\draw[vector] (O) -- (vec1)
coordinate[label={[below]$u_1$}] (u1);
%sum (vec1)+(vec2)
\draw[vector,very thick,blue] (O)--($(vec1)+(vec2)$)
coordinate (u1u2);
%rotated sum (u1)+(u2) -> u'1+u'2
\draw[vector,very thick,orange] (O)--([rotate=-90]u1u2)
coordinate (u'1u'2);
%rotated vectors
\draw[red,vector] (0,0) -- ([rotate=-90]vec1)
coordinate[label={[left]$u'_1$}] (u'1);
%
\draw[red,vector] (0,0) -- ([rotate=-90]vec2)
coordinate[label={[below]$u'_2$}] (u'2);
%angles between vectors by angles library, issue with angle radius=
%default angle radius=1cm and it does not scale accordingly
\pic[draw=gray] {angle={u'1--O--u'2}};
% rotation traces
\pic[draw=red, dashed, <-, angle radius=1.8cm] {angle={u'1--O--vec1}};
\pic[draw=blue, dashed, <-, angle radius=5.3cm] {angle={u'1u'2--O--u1u2}};
%vector sums labels
\coordinate[label={below:$w$}] (w) at (u1u2);
\coordinate[label={below:$w'$}] (w') at (u'1u'2);
% outgoing vector scaled accordingly but I'd rather prefer not
\pic at (O) {origin};
\end{tikzpicture}
\end{document}