Hola a todos, necesito escalar una imagen de Tikz, así que lo hice \begin{tikzpicture}[scale=<factor>]
pero las fotos no se escalan en consecuencia (se informa en el TikzManual).sección 18.2 La sintaxis de Pic). También quiero fotos escaladas, así que probé la sintaxis \begin{tikzpicture}[scale=0.4,every pic/.style={transform shape}]
pero no funcionó. Usar transformar forma como opción de cada imagen, es decir, \pic[angle radius=5.3cm,transform shape]
está bien, pero no quiero usarlo en todas las opciones de \pic
s. Tal vez sea un problema sólo con la biblioteca de ángulos (no probé con otras fotografías). Aquí están mis MWE, esto no funciona como se esperaba
\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}
El siguiente funciona correctamente,
\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}
Tal vez haya una mejor manera de lograrlo. Estoy abierto a ello, pero no cambiaría mi código desde cero.
Lo intenté every pic/.append style={transform shape}
pero sin resultado aparente. Como efecto secundario, el radio devector salienteen las últimas líneas del código está escalado, lo cual no quiero.
Respuesta1
Como desea agregar un estilo a cada \pic{angle}
, puede configurarlo pics/angle/.append style={/tikz/transform shape}
(debe indicar la ruta explícitamente, porque \pic
aquí se encuentra dentro del "directorio de ruta"):
\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}
Cambié algunos de los nombres de las coordenadas porque no estoy seguro de que +
incluir un nombre sea una buena idea. Siéntase libre de cumplir con esto o no.
Si no desea que (O)
se escalen los círculos, cree uno \pic
a partir de esto. Sabemos que \pic
los s no se ven afectados por el escalado y lo pics/angle/.append style={/tikz/transform shape}
aplicamos transform shape
solo al \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}