Направить стрелку на цель - PullRequest
0 голосов
/ 06 октября 2018

Я пишу инструкцию по эксплуатации Carom Billard на латексе.Иллюстрации сделаны с тикз.Мне нужна стрелка, которая всегда указывает от битка в направлении к прицельному шару и всегда одинаковой длины и на одинаковом расстоянии от битка.

У меня есть решение нарисовать стрелку из битка вобъект мяч и сокращение линии.Это сокращение, однако, должно выполняться вручную каждый раз, когда расстояние между шариками изменяется методом проб и ошибок.

Есть ли способ автоматизировать это, чтобы мне не приходилось менять длину вручную?

\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}

1 Ответ

0 голосов
/ 06 октября 2018

Вот как можно нарисовать биток (вы можете добавить 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);

enter image description here

...