我正在用Latex编写carom billard说明手册。插图是用tikz制作的。我需要一个箭头,该箭头始终从母球指向目标球,并且总是相同的长度,并且距母球的距离相同。
我有一个解决方案,画一个从母球到目标球的箭头并缩短线。但是,每次球之间的距离发生变化时,都必须通过反复试验手动进行缩短。
有没有一种方法可以自动执行此操作,所以我不必手动更改长度?
\documentclass[a4paper, 11pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows,arrows.meta}
\begin{document}
\begin{tikzpicture}[x=1mm, y=1mm]
% Units definitions
\def \tb {142} % width of table
\def \tl {2*\tb} % lenght of table
\def \d {\tb/4}; % diamonds
\def \c {\tb/3}; % Cadre
\def \bb {6.15}; % diameter of balls
% Cueball coordinate
\path (\c,\c) coordinate (B1);
% Objectball coordinate
\path (1.5*\bb,\c-\bb) coordinate (B2);
% Arrow
\draw [-Stealth, thick, shorten >=125, shorten <=30]
(B1) --
(B2);
% Cueball
\draw [fill=white] (B1)
node[above left = 5]{\small Cueball} % Beschriftung
circle (\bb/2);
% Objectball
\draw [fill=white] (B2)
node[above left = 5]{\small Objectball} % Beschriftung
circle (\bb/2);
\end{tikzpicture}
\end{document}
答案 0 :(得分:0)
以下是绘制提示杆的方法(可以将draw,red
添加到假线和圆上以查看其构造):
\def \distancetoball {6mm};
\def \sticklength {20mm};
% Define fake line that goes through the object ball and the cue ball
\path [name path=direction] ($(B1)!-\distancetoball-\sticklength!(B2)$) -- (B2);
% Define two fake circles around the cueball to place the cue stick
\path [name path=circle1] (B1) circle(\distancetoball);
\path [name path=circle2] (B1) circle(\distancetoball+\sticklength);
% Pick the intersection of the line with the two circles to be the two extremities of the cue stick
\path [name intersections={of=direction and circle1}];
\coordinate (tip) at (intersection-1);
\path [name intersections={of=direction and circle2}];
\coordinate (source) at (intersection-1);
% Draw the cue stick
\draw [-Stealth, thick] (source) -- (tip);