TikZ 내에서 pgf를 어떻게 사용할 수 있나요?

TikZ 내에서 pgf를 어떻게 사용할 수 있나요?

배경: 나는 Ti를 이해한다케이Z는 pgf 위에 구축되었습니다. 둘 다 pgf 매뉴얼에 설명되어 있습니다. 그러나 두 가지가 어떻게 연결되어 있는지 설명하는 설명서 섹션(존재하는 경우)을 찾을 수 없습니다. 나는 Ti의 높은 수준의 구성을 즐기기 때문에 이것이 나에게 문제가 됩니다.케이Z, 그러나 나는 액세스 방법을 모르는 pgf에서 유용한 기본 요소를 많이 발견했습니다.

예를 들어 다음과 같은 간단한 그림을 살펴보겠습니다.

두 개의 선분과 그 연장선의 교차점

두 개의 짧고 교차하지 않는 선분이 있습니다. 원은 연장된 선이 만나는 지점을 표시합니다. 선분과 노드 라벨은 Ti로 생성되었습니다.케이Z, pgf와의 교차점.

다음은 매뉴얼에서 발췌하여 약간 수정한 코드입니다.

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[x=20mm,y=20mm]
  \draw
  (.5,0) node[left](A){$A$} -- (1,.8) node[left]{B}
  (2,0) node[left](C){$C$} -- (1.5,1) node[right](D){D};
  \pgfpathcircle{%
    \pgfpointintersectionoflines
      {\pgfpointxy{.5}{0}}{\pgfpointxy{1}{.8}}
      {\pgfpointxy{2}{0}}{\pgfpointxy{1.5}{1}}}
    {2pt}
  \pgfusepath{stroke}
\end{tikzpicture}
\end{document}

분명히 코드는 DRY가 아닙니다. 좌표는 pgf 섹션에서 반복됩니다. 그러나 A~D 지점 자체가 계산 결과인 경우 이는 실행 가능한 옵션이 아닙니다. 또한 나는 할 수 있다그리다교차점이지만 할 수 없습니다사용Ti에서 추가 작업 중케이Z 레벨. 따라서 내 질문은 다음과 같습니다.

  • \pgfpointintersectionoflines다른 pgf 구문 에서 사용할 수 있는 점 A~D를 어떻게 표현합니까 ?
  • 그리고 Ti에서 추가로 사용하기 위해 pgf 세계에서 결과를 어떻게 추출합니까?케이Z월드?

나는 현재의 문제에만 적용되는 해킹이 아니라 일반화될 수 있는 답변을 찾고 있다는 점에 유의하십시오.

답변1

Torbjørn T.가 말하는 것 외에도 기존 노드/좌표를 \pgfpointanchor{<name>}{<anchor>}.

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[x=20mm,y=20mm]
  \draw
  (.5,0) node[left](A){$A$} -- (1,.8) node[left](B){B}
  (2,0) node[left](C){$C$} -- (1.5,1) node[right](D){D};  
   \pgfcoordinate{aux}{\pgfpointintersectionoflines
      {\pgfpointanchor{A}{east}}{\pgfpointanchor{B}{east}}
      {\pgfpointanchor{C}{east}}{\pgfpointanchor{D}{west}}}
   \pgfpathcircle{\pgfpointanchor{aux}{center}}{2pt}
  \pgfusepath{stroke}
  \draw (aux) -- (aux|-A.south);
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

답변2

나는 또 다른 해결책을 스스로 생각해 냈습니다. marmot의 답변만큼 좋지는 않지만 동일한 문제에 대한 다른 접근 방식이므로 다른 옵션 세트를 활성화할 수 있으므로 기록을 위해 여기에서 제공합니다.

\documentclass[tikz]{standalone}
\usetikzlibrary{math}
\begin{document}
\begin{tikzpicture}[x=20mm,y=20mm]
  \draw
  (.5,0) coordinate(A) node[left]{$A$} -- (1,.8) coordinate(B) node[left]{B}
  (2,0) coordinate(C) node[left]{$C$} -- (1.5,1) coordinate(D) node[right]{D};
  \tikzmath{
    coordinate \A; \A = (A);
    coordinate \B; \B = (B);
    coordinate \C; \C = (C);
    coordinate \D; \D = (D); }
  \pgfcoordinate{E}{
    \pgfpointintersectionoflines
      {\pgfpoint{\Ax}{\Ay}}{\pgfpoint{\Bx}{\By}}
      {\pgfpoint{\Cx}{\Cy}}{\pgfpoint{\Dx}{\Dy}}}
  \draw (E) circle[radius=2pt];
\end{tikzpicture}
\end{document}

거기까지 가는 과정에서 \pgfpoint(캔버스 좌표?) 와 \pgfpointxy(사용자 좌표)의 차이점을 알게 되었습니다.

관련 정보