3

Given point $A$ and point $B$, on the one hand, I would like to get a point that is an affine combination of $A$ and $B$, for example $1.2A-0.2B$, on the other hand, I would like to get the coordinate of the intersection point of $AB$'s extended line and $CD$.

The MWE is as follows.

\documentclass[notitlepage, 12pt]{amsart}
\usepackage{amsthm, amsmath, amsaddr, amssymb, graphicx, dsfont,}
 \usepackage[dvipsnames]{xcolor}
\renewcommand{\baselinestretch}{1.2}
  \usepackage{tikz}
  \usetikzlibrary{calc,intersections,through,backgrounds}
   \usepackage{pgfplots} 
   \usepackage[capposition=bottom]{floatrow}
   \usepackage{float}
   \pgfplotsset{compat=1.18}

\begin{document}

\thispagestyle{empty}

\begin{figure}[H]
\centering

\begin{tikzpicture}[xscale=18,yscale=18]


 \coordinate (A) at (0.2,0.3);

 \coordinate (B) at (0.3,0.2);

 \coordinate (C) at (0.4,0.2);

\coordinate (D) at (0.4,0.5);




    \end{tikzpicture}

   \caption{}

  \end{figure}




  \end{document}

Ypbor
  • 399
  • 1
    Please provide a minimal working example. Try calc. – cfr Mar 06 '24 at 03:24
  • @cfr I added a MWE. By the way, how can I add the code quickly? I have to add several spaces before each line manually... – Ypbor Mar 06 '24 at 04:08
  • point C and D are at the same coordinate - how do you draw a line through them – js bibra Mar 06 '24 at 04:17
  • @jsbibra My bad. I corrected the coordinate. – Ypbor Mar 06 '24 at 04:22
  • 2
    Please limit your question to one question. If you want a combination of two coordinates, see my answer below. If you want the intersection point of two lines, use the intersections library. – Sandy G Mar 06 '24 at 04:22
  • 1
    for extending a combination of coordinates see my answer here using tkz-euclide- https://tex.stackexchange.com/a/666573/197451 – js bibra Mar 06 '24 at 04:37
  • Highlight the code and hit ctrl-k or click the code button at the top of the dialogue. Or put three back ticks on a line of their own before and after the code. – cfr Mar 06 '24 at 18:32
  • Because you've asked two questions, you now have no good basis for accepting any answer, since each answer addresses one question. Please don't do this. Ask a followup question instead. We also can't sensibly link this to previous questions because we can't link to two. – cfr Mar 06 '24 at 18:35
  • @cfr I thought asking a related question immediately was inappropriate. Sorry for causing the trouble. – Ypbor Mar 07 '24 at 02:34
  • @Ypbor No problem. Asking a followup is fine. If you want to ask twenty, you should probably pace yourself, but two won't swamp the front page ;). Just link the first if they're related. – cfr Mar 07 '24 at 04:40

3 Answers3

3

Use the calc library.

enter image description here

\documentclass{article}

\usepackage{tikz} \usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture} \drawhelp linesnode{O} grid (7,6); \node at (3,1)(a){A}; \node at (2,3)(b){B}; \node at ($1.2(a)+1.5(b)$){C}; \end{tikzpicture}

\end{document}

Sandy G
  • 42,558
2

for the intersection part with tkz-euclide

enter image description here

MWE

\documentclass[11pt,a4paper]{article}

\usepackage{tkz-euclide} \usepackage{color}

\begin{document} \begin{tikzpicture} \tkzDefPoint(0,0){A} \tkzDefPoint(6,5){B} \tkzDrawSegmentblue

    \tkzDefPoint(0,5){C}
    \tkzDefPoint(6,0){D}
    \tkzDrawSegment[red](C,D)

    \tkzLabelPoints[xshift=-12pt, yshift=4pt](A,B,C,D)
    \tkzDrawPoints[size=4pt, fill=green, draw=green](A,B,C,D) 
    \tkzInterLL(A,B)(C,D) 

    \tkzGetPoint{O}

    \tkzDrawPoint[color=black,size=5mm,fill=white](O)

    \tkzLabelPoints[yshift=8mm](O)
\end{tikzpicture}

\end{document}

js bibra
  • 21,280
2

The intersection of two straight lines can be done in a simple way as was explained in the first versions of tikz, see manual 1.18 here: tikz manual version 1.18 Although undocumented in later versions of tikz, this syntax is still valid and very convenient for geometric constructions.

\coordinate[label=I] (I) at (intersection of A--B and C--D);

For the affine combination, there are barycentric coordinates, see the latest manual.

\coordinate[label=E](E) at (barycentric cs:A=1.2,B=0.2);

enter image description here

\documentclass[notitlepage, 12pt]{amsart}
\usepackage{amsthm, amsmath, amsaddr, amssymb, graphicx, dsfont,}
\usepackage[dvipsnames]{xcolor}
\renewcommand{\baselinestretch}{1.2}

\usepackage{tikz} \usetikzlibrary{calc,intersections,through,backgrounds}

\usepackage{pgfplots} \usepackage[capposition=bottom]{floatrow} \usepackage{float} \pgfplotsset{compat=1.18}

\begin{document} \thispagestyle{empty}

\begin{figure}[H] \centering

\begin{tikzpicture}[xscale=18,yscale=18] \coordinate[label=A] (A) at (0.2,0.3); \coordinate[label=B] (B) at (0.3,0.2); \coordinate[label=C] (C) at (0.4,0.2); \coordinate[label=D] (D) at (0.4,0.5);

% affine combination of $A$ and $B$ \coordinatelabel=E at (barycentric cs:A=1.2,B=0.2);

% intersection of (AB) and (CD) \coordinate[label=above right:I] (I) at (intersection of A--B and C--D); \pgfgetlastxy{\XCoord}{\YCoord}

% construction of (AB) and (CD) \draw($(A)!2.5!(B)$)--($(B)!1.5!(A)$); \draw($(C)!1.5!(D)$)--($(D)!1.5!(C)$);

\foreach \a in {A,B,C,D,E,I}\draw[fill=black] (\a) circle(0.1pt);

\node[anchor=north,align=left] at (current bounding box.south){$x_I=\XCoord$\ $y_I= \YCoord$};

\end{tikzpicture} \caption{} \end{figure} \end{document}

AndréC
  • 24,137