我正在寻找类似的东西
pointA to pointB, length
其中pointA
是起点,pointB
是终点,length
是从起点到终点的线长。
\documentclass[border=10mm]{standalone}
\usepackage{tikz}
\usetikzlibrary
{%
positioning,
shapes.geometric
}
% FOLLOWING STYLES ARE NOT IMPORTANT AND CAN BE SKIMMED THROUGH;
\tikzset
{%
TRIANGLE/.style=
{%
isosceles triangle,
isosceles triangle apex angle=60,
minimum size=30mm,
shape border rotate=270,
inner sep=0mm,
outer sep=0mm,
line width=2mm,
draw
},
LINE/.style=
{%
line width=2mm,
draw=red
}
}
\begin{document}
\begin{tikzpicture}
\path node[TRIANGLE](T){};
\path[LINE]
% FOLLOWING COORDINATES SHOULD SERVE AS POINTS
% BETWEEN WHICH A LINE OF ANY SPECIFIED LENGTH CAN BE DRAWN,
% NOT OF A FIXED LENGTH SPANNING FROM ONE POINT TO ANOTHER (LIKE IN THIS EXAMPLE);
% IT CAN BE DONE USING COMPLICATED ARITHMETIC
% BUT ARE THERE ANY MEANS IN PGF (OR ELSE) TO MAKE IT SIMPLER?
(T.right corner)--(T.left side);
\end{tikzpicture}
\end{document}
输出(绿线是红线应该停止的地方):
答案1
图书馆calc
可以做到这一点。
\documentclass[border=10mm]{standalone}
\usepackage{tikz}
\usetikzlibrary
{%
calc,
positioning,
shapes.geometric
}
% FOLLOWING STYLES ARE NOT IMPORTANT AND CAN BE SKIMMED THROUGH;
\tikzset
{%
TRIANGLE/.style=
{%
isosceles triangle,
isosceles triangle apex angle=60,
minimum size=30mm,
shape border rotate=270,
inner sep=0mm,
outer sep=0mm,
line width=2mm,
draw
},
LINE/.style=
{%
line width=2mm,
draw=red
}
}
\begin{document}
\begin{tikzpicture}
\path node[TRIANGLE](T){};
\path[LINE]
% FOLLOWING COORDINATES SHOULD SERVE AS POINTS
% BETWEEN WHICH A LINE OF ANY SPECIFIED LENGTH CAN BE DRAWN,
% NOT OF A FIXED LENGTH SPANNING FROM ONE POINT TO ANOTHER (LIKE IN THIS EXAMPLE);
% IT CAN BE DONE USING COMPLICATED ARITHMETIC
% BUT ARE THERE ANY MEANS IN PGF (OR ELSE) TO MAKE IT SIMPLER?
($(T.right corner)!.3!(T.left side)$)--(T.left side);
\end{tikzpicture}
\end{document}