5

Is there a way to produce the segment using the following code to draw a line A-B plus 1cm to a point C, obviously without calculating the coordinates.

\documentclass{article}   
\usepackage{tkz-euclide}

\begin{document}

\begin{tikzpicture}

\tkzDefPoint(0,0){A}
\tkzDefPoint(2,3){B}

\tkzDrawSegment(A,B)
\tkzDrawPoints(A,B)
\tkzLabelPoints(A,B)

\end{tikzpicture}

\end{document}

Thanks

Paul A
  • 1,055
  • 4
  • 14

2 Answers2

5

One possibility

\documentclass{article}   
\usepackage{tkz-euclide}

\begin{document}

\begin{tikzpicture} \tkzDefPoint(0,0){A} \tkzDefPoint(2,3){B} \tkzDefPointWithlinear normed,K=-1
\tkzGetPoint{C} \tkzDrawSegments(A,B B,C) \tkzDrawPoints(A,B,C) \tkzLabelPoints(A,B,C) \end{tikzpicture} \end{document}

Another possibility

 \tkzDefPointWith[colinear= at B,normed](A,B)

Note that if you want C to be aligned with A and B, you'll have to make a calculation to determine the slope of (AB). In general, the principle here is to divide the vector AB by its norm.

enter image description here

Alain Matthes
  • 95,075
2

This code uses \tkzDefPointBy[translation=from A to B](1,0) to create point C located 1cm beyond point B along the line AB. This avoids the need for orthogonal vector calculations.

\documentclass{article}
\usepackage{tkz-euclide}

\begin{document}

\begin{tikzpicture} \tkzDefPoint(0,0){A} \tkzDefPoint(2,3){B}

\tkzDrawSegment(A,B)
\tkzDrawPoints(A,B)
\tkzLabelPoints(A,B)

% Extend the line segment AB by 1cm to create point C
\tkzDefPointBy[translation=from A to B](1,0)
\tkzGetPoint{C}

\tkzDrawSegment(B,C)
\tkzDrawPoint(C)
\tkzLabelPoints(C)

\end{tikzpicture}

\end{document}

enter image description here

Sebastiano
  • 54,118