如何按特定比例延长一条线?

如何按特定比例延长一条线?

给定点$A$和点$B$,一方面我想求出一个$A$和$B$的仿射组合的点,比如$1.2A-0.2B$;另一方面我想求出$AB$的延长线与$CD$的交点坐标。

MWE 如下。

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

答案1

使用calc图书馆。

在此处输入图片描述

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}
\draw[help lines](0,0)node{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}

答案2

对于与tkz-euclide

在此处输入图片描述

平均能量损失

\documentclass[11pt,a4paper]{article}

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

\begin{document}
    \begin{tikzpicture}
        \tkzDefPoint(0,0){A} 
        \tkzDefPoint(6,5){B} 
        \tkzDrawSegment[blue](A,B) 
        
        \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}

答案3

两条直线的相交可以通过一种简单的方式完成,如 tikz 的第一个版本中所解释的那样,请参阅此处的手册 1.18:tikz 手册版本 1.18尽管在 tikz 的后续版本中没有记录,但该语法仍然有效并且对于几何构造非常方便。

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

对于仿射组合,有重心坐标,请参阅最新的手册。

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

在此处输入图片描述

\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$ 
\coordinate[label=E](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}

相关内容