我编写了一个 C# 程序,通过 Latex 生成其输出。下面是所需 Latex 的一部分。有两个“范围”看起来非常相似,因此可以通过 C# for 循环生成以避免重复代码。范围必须尽可能相同。
我怀疑我可以为左右“范围”提供它们自己的本地(镜像?)坐标系。
我的问题是:有人可以指出我正确的方向来定义一个有用的范围局部坐标系,以便范围内的代码变得更加相同吗?
看一下矩形:那些减号很烦人......
我尝试了 xscale=-1/yscale=-1 选项,但似乎不起作用。
忘记节点标签吧。它们只是用来调试的。
\documentclass[11pt,a4paper]{article}
\usepackage[per-mode=symbol]{siunitx}
\usepackage{amsmath}
\usepackage{pgfplots}
\usepackage{amssymb}
\usepackage{xcolor}
\usepackage{rotating}
\usepackage{tikz}
\tikzset{every picture/.style={line width=0.75pt}}
\usetikzlibrary{arrows.meta,calc,decorations.markings,math,quotes,angles,plotmarks}
\begin{document}
\begin{figure}[h]
\begin{tikzpicture}[x=0.75pt,y=0.75pt]
\def \angleA {20} % left and right rotations
\def \angleB {-30}
\def \lengthA {50} % vector lengths
\def \lengthB {60}
\def \dist {300} % distance between A and B
\coordinate (A) at (0,0);
\coordinate (C) at (\lengthA,0);
\path (A)-- ++(\dist,0) coordinate (B) -- ++(-\lengthB,0) coordinate(D);
\draw [black, dotted,thick](A)--(B); % connecting line
% the (fixed) resultant force vectors:
\draw [-stealth,green] (A)-- (C) node [black, below]{\tiny{C}};
\draw [-stealth,green] (B)-- (D) node [black, below]{\tiny{B}};
\begin{scope}[rotate around={\angleA:(A)}]
\draw[gray, fill=gray!40!white] (A)-- ++(0,100)-- ++(-5,0)-- ++(0,-200)-- ++(5,0)--cycle;
% overlay C with G. G will be rotated 'away', C will remain where it is,
% because it is outside the rotating scope:
\coordinate (G) at (C);
\draw [-stealth,blue] (A) -- (A|-G) node [black,right] {\tiny{K}};
% Save endpoint in a
\draw [-stealth,red] (A)-- (A-|G) coordinate(a) node [black,right]{\tiny{G}};
\pic[pic text=\tiny{$\ang{\angleA}$},blue,fill=cyan!30,draw, angle eccentricity=1.5, angle radius=0.8cm]{angle=C--A--a};
\end{scope}
\begin{scope}[rotate around={\angleB:(B)}]
\draw [gray, fill=gray!40!white] (B)-- ++(0,100)-- ++(5,0)-- ++(0,-200)-- ++(-5,0)--cycle;
\coordinate (H) at (D);
\draw [red,-stealth] (B)-- (B-|H) coordinate(a) node [black,left]{\tiny{H}};
\draw [blue,-stealth] (B)-- (B|-H) node [black,left]{\tiny{K}};
\pic[pic text=\tiny{$\ang{\angleB}$},blue,fill=cyan!30,draw, angle eccentricity=1.5,angle radius=0.8cm]{angle=a--B--D};
\end{scope}
\path (A)--(-0.3cm,0) node[left, red]{\textbf{A}};
\path (B)-- ++(0.3cm,0) node[right, green!40!gray] {\textbf{B}};
\end{tikzpicture}
\end{figure}
\end{document}